Using grep, sed, awk, cut, sort, uniq, tr, and pipelines to filter and transform text.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What does grep do?
Show answer
Searches for lines matching a regular expression pattern
- How do you make grep search case-insensitive?
Show answer
Use the -i flag: grep -i pattern file
- What does grep -v do?
Show answer
Inverts the match, showing lines that do NOT match the pattern
- What flag enables extended regular expressions in grep?
Show answer
-E (or --extended-regexp)
- What does grep -c do?
Show answer
Counts and displays the number of matching lines
- What does grep -n do?
Show answer
Shows line numbers before each matching line
- What does grep -o do?
Show answer
Shows only the matching part, not the entire line
- What is sed?
Show answer
A stream editor that reads text line by line and applies edit commands
- What does sed s/old/new/ do?
Show answer
Substitutes the first occurrence of old with new on each line
- How do you substitute all occurrences of a pattern on a line with sed?
Show answer
Add the g flag: sed s/old/new/g
- What does sed -i do?
Show answer
Edits files in-place, modifying the original file instead of printing to stdout
- What does sed 3d do?
Show answer
Deletes line 3 from the output
- How do you delete a range of lines in sed?
Show answer
Use comma notation: sed 1,5d deletes lines 1 through 5
- What does sed p do?
Show answer
Prints a line (usually used with sed -n to suppress normal output)
- What is the basic structure of an awk program?
Show answer
pattern { action } - awk finds lines matching pattern and executes the action