Pattern Matching
grep
Search text using regular expressions. Usage:grep [options] pattern [file...]
Options:
-i- Case-insensitive search-v- Invert match (show non-matching lines)-n- Show line numbers-c- Count matching lines-l- List files with matches-r- Recursive search-w- Match whole words only-E- Extended regex (default in Lifo)
sed
Stream editor for text transformation. Usage:sed [options] 'expression' [file...]
Options:
-i- Edit files in-place-e- Add script expression
s/pattern/replacement/- Substitutes/pattern/replacement/g- Substitute all occurrencess/pattern/replacement/i- Case-insensitive substituted- Delete linesp- Print lines
awk
Pattern scanning and processing language. Usage:awk [options] 'program' [file...]
Options:
-F sep- Field separator (default: whitespace)
$0- Entire line$1, $2, ...- Field valuesNR- Line numberNF- Number of fields
Line Selection
head
Output the first part of files. Usage:head [options] [file...]
Options:
-n NUM- Output first NUM lines (default: 10)
tail
Output the last part of files. Usage:tail [options] [file...]
Options:
-n NUM- Output last NUM lines (default: 10)
Sorting and Filtering
sort
Sort lines of text. Usage:sort [options] [file...]
Options:
-r- Reverse order-n- Numeric sort-u- Unique (remove duplicates)-k N- Sort by field N
uniq
Report or filter repeated lines. Usage:uniq [options] [file]
Options:
-c- Count occurrences-d- Only show duplicates-u- Only show unique lines
Text Manipulation
cut
Remove sections from lines. Usage:cut [options] [file...]
Options:
-d delim- Field delimiter-f list- Select fields (e.g., 1, 1-3, 1,3)-c list- Select characters
tr
Translate or delete characters. Usage:tr [options] set1 [set2]
Options:
-d- Delete characters-s- Squeeze repeated characters
rev
Reverse lines characterwise. Usage:rev [file...]
Examples:
tac
Concatenate and print files in reverse. Usage:tac [file...]
Examples:
Line Processing
wc
Count lines, words, and characters. Usage:wc [options] [file...]
Options:
-l- Count lines only-w- Count words only-c- Count characters only
nl
Number lines of files. Usage:nl [options] [file...]
Options:
-b a- Number all lines-b t- Number non-empty lines only
seq
Print numeric sequences. Usage:seq [first] [increment] last
Examples:
File Comparison
diff
Compare files line by line. Usage:diff [options] file1 file2
Options:
-u- Unified format-c- Context format-q- Brief (report only if files differ)
Encoding
base64
Base64 encode/decode data. Usage:base64 [options] [file]
Options:
-d- Decode data
strings
Print printable character sequences. Usage:strings [file...]
Examples:
Text Editors
nano
Simple text editor. Usage:nano [file]
Examples:
less
File pager for viewing text. Usage:less [file]
Examples: