Skip to main content
Ganesh Joshi
Back to Cheatsheets

grep, sed, and awk

Updated 2026-02-15

grep for search, sed for replace, awk for columns. Common one-liners and regex in shell.

grep

  • grep 'pattern' file

    Match lines.

  • grep -r 'pattern' dir

    Recursive.

  • grep -i 'pattern'

    Ignore case.

  • grep -E 'regex'

    Extended regex.

  • grep -v 'pattern'

    Invert match.

sed and awk

sed 's/old/new/g' file (replace). sed -i for in-place (GNU). awk '{ print $1 }' print first column. awk -F',' for CSV. awk '/pattern/ { print }' filter.

grep, sed, and awk | Cheatsheet | Ganesh Joshi