Files
My-Notes/linux/grep.md
2026-05-01 23:44:02 +03:00

333 B

Useful grep arguments

Search without case sensitivity

cat file.txt | grep -i "pattern"

Add lines to match pattern

Before

cat file.txt | grep -B 3 "pattern"

After

cat file.txt | grep -A 3 "pattern"

Both

cat file.txt | grep -C 3 "pattern"

Show line numbers with matches

cat file.txt | grep -n "pattern"