Advertisement

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.txt

Sed - 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
Advertisement

Awk - Text Processing

Process text by fields.

awk '{print $1}' file.txt
awk -F":" '{print $1}' /etc/passwd
awk '/pattern/ {print $0}' file.txt

Cut - Extract Columns

Extract fields from text.

cut -d":" -f1 /etc/passwd
cut -c1-10 file.txt

Sort

Sort text lines.

sort file.txt
sort -r file.txt
sort -n file.txt

Uniq

Remove duplicates.

sort file.txt | uniq
uniq -c file.txt
Last updated: January 2026
Advertisement