Sed Awk and Grep
grep (Global Regular Expression Print)
Searches text for patterns (strings or regex), most often used for finding lines that match (or don’t match) a pattern. Searches input for lines that match a regular expression and prints those lines (or optionally the count, filenames, etc.).
Examples:
# Find lines containing "error" in a file
grep "error" logfile.txt
# Case-insensitive search
grep -i "error" logfile.txt
# Show line numbers of matches
grep -n "error" logfile.txt
# Show lines that do NOT match
grep -v "error" logfile.txt
# Show all lines containing the word "error" (case‑insensitive) in a log file
grep -i "error" /var/log/syslog
# Count how many times "TODO" appears in source files
grep -c "TODO" *.c *.hsed (Stream Editor)
Edits text streams, mostly used for substitution, deletion, insertion, of strings within files. Reads a stream line‑by‑line, applies editing commands (substitutions, deletions, insertions, etc.), and writes the result.
Examples
AWK
Pattern scanning and processing language. Mostly used for working with structured data (columns), calculations, reports. Scans input line‑by‑line, splits each line into fields (default whitespace), and executes user‑defined actions when patterns match.
Examples
Last updated