Common sed commands for editing and reformatting text during pentests.
Sed is a stream editor that lets you search, replace, and reformat text without opening a file in an editor. It’s especially handy for cleaning up wordlists and extracted data during an engagement.
sed -n '2345p' flag19 # Print only line 2345 of a file (awk 'NR==2345' flag19 works too)sed 's/,/\n/g' comma_separated.txt > one_per_line.txt # Put each comma-separated value on its own linesed ':a;N;$!ba;s/\n/", "/g' subdomains.txt | sed 's/^/"/;s/$/"/' # Join every line into one comma-separated, quoted stringsed 's/\./\n/g' subdomains.txt > words.txt # Split text at every . and put each part on its own linewget -q -O - https://example.com/docs | sed -n 's/.*<h4[^>]*>\(.*\)<\/h4>.*/\1/p' # Extract the text inside every <h4> tag from a downloaded pagefind . -type f -exec sed -i 's/.*://' {} \; # Strip everything before the first colon on every line, in every file in the current treesed 's/[^[:print:]]//g' wordlist.txt | grep -E '^.{8}$' # Strip non-printable characters, then keep only 8-character words



