Skip to content

grep

This command is a must for many roles such as linux system admins, devops ...

Basic

Filter out lines with matching pattern:

grep pattern somefile.txy
grep -v pattern somefile

Look/Search for content of the files recursively:

-i case insensitive; -R recursive;

grep -Ri somepattern *

Count how many time word appears:

grep -c RUN Dockerfile

Also grep lines before and after:

grep pattern -A 20 -B 20 somefile

grep more stuff at once

sudo netstat -tulpen | egrep -E "25|587|143|465|993"