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 Path variable?What is its use?

1 Answers  


how to read systems current date and time

4 Answers  


How to set an array in linux?

0 Answers  


How do we create command aliases in a shell?

0 Answers  


Why are there shells on the beach?

0 Answers  


How to debug the problems encountered in the shell script/program?

0 Answers  


How to replace following lines, catch (DAOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } catch (BOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw e; } catch (Exception e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } Needs to be changed in to, catch (DAOException e) { AppException.handleException (null, null, e, null, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); } catch (BOException e) { AppException.handleException (null, null, null, e, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 0); } catch (Exception e) { AppException.handleException (null, null, null, null, null, e, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); }

0 Answers   Wipro,


What happens when you type ls?

0 Answers  


How does path variable work?

0 Answers  


What are the different types of variables used in shell script?

0 Answers  


What is the syntax of "expr" command?

2 Answers  


what are command line arguments? what is the need of those?

1 Answers   Flipkart,


Categories