Prints/filters lines that match a Regular Expression (RE) pattern.
echo -n 'Hello World!\nI''m Going!\nGoodbye!' | grep "Good"
Filter file content
cat ~/.bashrc | grep "alias"
grep "alias" ~/.bashrc
Filter pattern, with PERL flavour
cat ~/.bashrc | grep -P "^#"
Prints lines beginning with
echo -n 'Hello World!\nI''m Going!\nGoodbye!' | grep -i "go"
I'm Going! Goodbye!
echo -n 'Hello World!\nI''m Going!\nGoodbye!' | grep -i -v "go"
About Living in the Shell
Obsessed with doing things in the shell, I’ve decided to share my daily struggles on living in the shell as terse but informative posts.