grep
grep -i "pattern" fileCase-insensitive search.
grep -r "pattern" /path/to/dirRecursive search through a directory.
grep -v "pattern" fileInvert match — show lines not matching the pattern.
grep -A 3 -B 2 "pattern" fileShow 2 lines before and 3 lines after matching lines.
grep -E "foo|bar" fileUse extended regex to match multiple patterns.
grep -n "pattern" fileShow line numbers where matches occur.
awk
awk '{print $1}' filePrint the first column.
awk -F ":" '{print $1, $3}' /etc/passwdUse : as a field separator, print fields 1 and 3.
awk '$3 > 100' fileOnly show lines where the third column is greater than 100.
awk '{sum += $2} END {print sum}' fileCalculate the sum of the second column.
awk 'NR % 2 == 0' filePrint every second line (even lines).
Files
du -sh ./*Show size of every item in the current directory.
find . -type f -mtime -3Find files modified in the last 3 days.
find . -name "*.log" -exec rm {} \;Find and delete all .log files.
sort -k2 -n fileSort file numerically by the second column.
sort file | uniq -c | sort -nrCount and rank duplicate lines.
Tidbits
Replace last command
ncim hello.md
^ncim^nvim^Remove text and square brackets from file names
rename 's/\ \[.*\]//' *