Grep
2025-09-14
ignore commented and empty lines
grep -v "^#\|^$" /path/to/dir
count number of empty lines
grep -c "^$" ..
only IP address
grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
returning lines before and after match (e.g. ‘bbo’)
# return also 3 lines after match
grep -A 3 'bbo'
# return also 3 lines before match
grep -B 3 'bbo'
# return also 3 lines before and after match
grep -C 3 'bbo'
lines without word (e.g. ‘bbo’)
grep -v bbo filename
grep all content of a fileA from fileB
grep -f fileA fileB