Grep - Search Text
Search for pattern in files.
grep "pattern" file.txt
grep -i "pattern" file.txt
grep -r "pattern" dir/
grep -n "pattern" file.txt
grep -v "pattern" file.txtSed - Stream Editor
Find and replace text.
sed 's/old/new/' file.txt
sed 's/old/new/g' file.txt
sed -i 's/old/new/g' file.txt
sed '/pattern/d' file.txt
Awk - Text Processing
Process text by fields.
awk '{print $1}' file.txt
awk -F":" '{print $1}' /etc/passwd
awk '/pattern/ {print $0}' file.txtCut - Extract Columns
Extract fields from text.
cut -d":" -f1 /etc/passwd
cut -c1-10 file.txtSort
Sort text lines.
sort file.txt
sort -r file.txt
sort -n file.txtUniq
Remove duplicates.
sort file.txt | uniq
uniq -c file.txtCommon mistakes / Pitfalls
- People often copy a command or pattern without adapting placeholders, which can break production workflows unexpectedly.
- It is easy to forget environment-specific differences, so always verify behavior in your shell, runtime, or API gateway before shipping.
- Many errors come from skipping small validation steps, so test with realistic sample input before relying on the result.
Last updated: February 2026