What is the syntax of "grep" command?

Answers were Sorted based on User's Feedback



What is the syntax of "grep" command?..

Answer / jayachandran.g.r

syntax of "grep" command


syntax: grep {word to lookup} {filename}



Ex: grep man test

Is This Answer Correct ?    29 Yes 6 No

What is the syntax of "grep" command?..

Answer / satchi

Grep is a filter used for pattern matching in shell script.

It searches for the patern if file name is give, or else it
will look for the input data using pipe(|)

Syntax:

1. Grep <patern to search> <Filename>
2. cat <filename> | grep <Patern to search.>

we can use -i option to ignore case sensitiveness.There are
so many options available.you have to explore that.

Is This Answer Correct ?    18 Yes 4 No

What is the syntax of "grep" command?..

Answer / vasanth

grep: Find lines in a file that match a regular expression

syntax: grep [options] pattern [files]

Useful Options : -v, -l, -L, -c, -n, -b, ,-i

-v Print only lines that donot match the regular expression
-l Print only names of files that contains matching
lines,not the line themseleves

for furthur information
pls ref. linux pocket guide by Daniel J. Barrett (page-71)

Is This Answer Correct ?    14 Yes 4 No

What is the syntax of "grep" command?..

Answer / kaustubh

grep command is a utility which helps in searching pattern
from the given file.

example

grep "pattern" /home/username/somefile.txt

it ll search all lines in the file somefile.txt and will
print the line which contains pattern.

there are many options as
-v = invert
-i = ignorecase
-c = count
-l = filename
-r = recursive

Is This Answer Correct ?    7 Yes 6 No

Post New Answer

More Shell Script Interview Questions

What is the difference between running a script as ./scriptname.sh and sh scriptname.sh

1 Answers  


What is MUTEX?

1 Answers  


how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?

0 Answers  


There are three departments A,B and C.Write a query to display the names of all the persons( in departments other than A) who are paid higher than the person receiving the lowest salary in DEPT A

1 Answers   Wipro,


What is the use of .sh file?

0 Answers  






What is shell scripting?

0 Answers  


how to search for vowels a,e,i,o,u appearing in the same sequence in a file

4 Answers   Amazon,


What is the use of "shift" command in passing parameters?

1 Answers  


What are the different types of shell scripting?

0 Answers  


determine the output of the following command: echo ${new:-variable}

0 Answers  


what is the meaning of First line of shell script ,what is meaning of #! pleas explain brifly

4 Answers  


How do you rename the files(*.sh) with file names containing space in it?for example "interview question.sh" needs to rename to "interview-question.sh". Appreciate your inputs.Thanks.

5 Answers   Wells Fargo,


Categories