Question:
What is the use of ‘grep’ command?
Answer:
‘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 Source: CoolInterview.com
grep word file Here file is the name of a file in which you want to search for word. The grep command displays every line in file that contains word. When you specify more than one file, grep precedes each of the output lines with the name of the file that contains that line. Source: CoolInterview.com
Answered by: piku | Date: 3/24/2009
| Contact piku
grep used to search a pattern from input.
e.g. grep [pattern] [file1] [file2] [file3] ...
case Sensitive $ grep 'oracle' employee.txt
case in-sensitive $ grep -i 'ORACLE' employee.txt
exclude the pattern $ grep -v 'ORACLE' employee.txt will result into lines which DOES NOT CONTAIN ORACLE word.
$cat eployee.txt|grep ORACLE
Regards, Gajanan Source: CoolInterview.com
Answered by: gajanan | Date: 4/13/2009
| Contact gajanan
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|