💾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."
Making Wordlists

For example the following commands extracts the first (usernames) and fourth (password hashes) fields, which are separated by colons (:):

awk '{print $1}' FS=':' dump.txt > users.txt
awk '{print $4}' FS=':' dump.txt > hashes.txt

Last updated