💾Regex
Regular Expressions
Basic Tricks
Print uncommented lines
cat example | grep -Ev "^#" | grep .
Extracts text within quotes
sed 's/"\([^"]*\)"/\1/g' filename
Swap to Unix-style
sed -i 's/\r$//' file.sh
Set a loop
until ! ./poc.sh | grep -q "[x] ERROR"; do :; done; echo "No ERROR found, script finished successfully."
grep multiple extensions (JPG and JPEG)
find . -type f | grep -ie "cats.*\.\(jpe?g\|png\|gif\)$"
Last updated