what is the use of "grep" command?

Answers were Sorted based on User's Feedback



what is the use of "grep" command?..

Answer / bharath

grep command is used to search a string or a keyword in a
file.
syntax:
grep 'keyword' file

Is This Answer Correct ?    9 Yes 3 No

what is the use of "grep" command?..

Answer / kiran sangeri

grep is one of many standard UNIX utilities. It searches
files for specified words or patterns. First clear the
screen, then type
% grep science science.txt
As you can see, grep has printed out each line containg the
word science.
Or has it ????
Try typing
% grep Science science.txt
The grep command is case sensitive; it distinguishes
between Science and science.
To ignore upper/lower case distinctions, use the -i option,
i.e. type
% grep -i science science.txt
To search for a phrase or pattern, you must enclose it in
single quotes (the apostrophe symbol). For example to
search for spinning top, type
% grep -i 'spinning top' science.txt
Some of the other options of grep are:
-v display those lines that do NOT match
-n precede each matching line with the line number
-c print only the total count of matched lines

Is This Answer Correct ?    3 Yes 1 No

what is the use of "grep" command?..

Answer / vasu

To filter desire data.
Ex: In history, to see all the commands which have
particular word like cd
#history | grep cd

Is This Answer Correct ?    2 Yes 0 No

what is the use of "grep" command?..

Answer / kk11749

for example I need for list of directories means
ls -r | grep "^d"
It will be display only directories

Is This Answer Correct ?    0 Yes 0 No

what is the use of "grep" command?..

Answer / durgesh srivastava

search pattern of a file system it is use of grep

Is This Answer Correct ?    0 Yes 0 No

what is the use of "grep" command?..

Answer / pavankumar

grep is used to matching a pattern in a file...
we can use regular expressions in conjuction with grep.
suppose for example if you want to find the all occurences of
pavan in a file, you can use...
grep pavan *
it searches all files in the current directory files and
returns all those files which contain pavan.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Unix Commands Interview Questions

what is the difference between Touch & cat command

21 Answers   QA,


what is the command to find out the difference between files and folders?

6 Answers  


How is the command '$cat file2 ' different from '$cat >file2 and >> redirection operators ?

0 Answers  


What is the use of cut command in unix?

0 Answers  


How do I run a bash script?

0 Answers  






Write a command that will allow a unix system to shut down in 15 minutes, after which it will perform a reboot.

0 Answers  


What is time_t?

0 Answers  


Which command is used to restrict incoming messages?

0 Answers  


When the shell is reading the command line what is the difference between text enclosed between double quotes ( ” ) and text enclosed between signal quotes ( ’ )?

3 Answers  


what is the difference between SED and GREP ? Which one is more better and why?

4 Answers   IBM,


What is the pipe command?

0 Answers  


What is the comma to show the space allocation of files?

0 Answers  


Categories