how to use grep command code example

Example 1: linux search for line in file

grep -R "keyword" /directory/

Example 2: how to grep

grep 'word' filename
fgrep 'word-to-search' file.txt
grep 'word' file1 file2 file3
grep 'string1 string2'  filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName
grep [-options] pattern filename
fgrep [-options] words file

Example 3: how to use grepper

//O Hello! Welcome to the first  
//Query & Answer system for coders.

//Grepper answers like this will popup 
//when you google search a code related problem. 

//If nothing pops up, You can add answers to your 
//search query by pressing “a” from google 
//or by clicking on the “easy code snag” button |G| on 
//any code snippets around the web you come across,
//that code snippet will popup for you and others
//the next time you run into the same problem.

//P.S. Show your gratitute if an answers helps you,
//by upvoting it or donating to the developer.  

//Holla at us with questions, concerns or your lonely 
//and want to talk: [email protected]

Example 4: what can I do with grep command that is useful

15 Practical Grep Command Examples In Linux / UNIX