GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Unix Commands
Go To First  |  Previous Question  |  Next Question 
 Unix Commands  |  Question 21 of 74    Print  
What is the use of ‘grep’ command?
‘grep’ is a pattern search command. It searches for the pattern, specified in the command line with appropriate option, in a file(s).
Syntax :      grep
Example :    grep 99mx mcafile



  
Total Answers and Comments: 3 Last Update: November 21, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 31, 2006 09:42:44   
kishore kumar        

RE: What is the use of ‘grep’ command?

GREP is pattern checking command .

it will contain many option like -c and soon

it is very useful when checking for pattern from the file


 
Is this answer useful? Yes | No
March 31, 2006 20:13:19   
myquery Member Since: March 2006   Contribution: 14    

RE: What is the use of ‘grep’ command?
Grep :command is used to search for a string in a file.
 
Is this answer useful? Yes | No
November 21, 2006 05:11:19   
muru        

RE: What is the use of ‘grep’ command?
Grep - stands for Globally Search a Regular Expression and Print. It is used to search a given string/pattern under the given path and list out all the occurances of it in a file or set of files. Following are the options available for grep command. 1. grep muru . - this command search for the word muru in all the files under the current directory and print its occurances 2. grep -v muru sample.txt - this command prints all the lines in sample.txt that doesn't contain the string muru 3. grep -s muru sample.txt - this command suppresses error string if any 4. grep -n muru sample.txt - similar to example-1 but it also displays the line number along with the lines 5. grep -l muru . - similar to example-1 but here it will display only the name of the files which contains the string muru and not the lines it contains 6. grep -i muru . - similar to example-1 but it is case in sensitive 7. grep -c muru . - similar to example-1 it also displays total count (ie) total number of occurances of the string 8. grep -q muru . - if the string is found in any file then the command exit with value 0 . It will not output anything. 9. grep -e muru -e India . - used to search more than one pattern at a time
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape