What is the syntax of "grep" command?
Answers were Sorted based on User's Feedback
syntax of "grep" command
syntax: grep {word to lookup} {filename}
Ex: grep man test
Is This Answer Correct ? | 29 Yes | 6 No |
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 |
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 |
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 |
What is mac default shell?
Explain how you Automate your application using Shell scripting.
I have 2 files and I want to print the records which are common to both.
What is k shell?
How to initialize a directory size to a variable??
What does .sh file contain?
How do we delete all blank lines in a file?
How do I open the shell prompt?
How to get the first line from a file using just the terminal?
In a file , how to retrieve the lines which are the multiples of 50 ? like 50,100,150th lines etc.
How do I set bash as default shell mac?
What is a batch file used for?