Easily find issues by searching: #<Issue ID>
Example: #1832
Easily find members by searching in: <username>, <first name> and <last name>.
Example: Search smith, will return results smith and adamsmith
Aqua Data Studio / nhilam |
Follow
827
|
\grep | |
Finds lines matching a specified pattern | |
Syntax | |
\grep [OPTION ...] PATTERN [FILE ...] |
|
Description | |
\grep searches the named input FILEs, or standard input if no files are named, for lines containing a match to the given PATTERN. By default, \grep prints the matching lines. |
|
Options | |
-c Suppress normal output; instead print a count of matching lines for each input file. With the -v option, count non-matching lines. |
|
-e PATTERN Use PATTERN as the pattern. This can be used to specify multiple search patterns. |
|
-f FILE Obtain patterns from FILE, one per line. This can be used to protect a pattern beginning with a hyphen (-). |
|
-H Print the file name for each match. This is the default when there is more than one file to search. |
|
-h Suppress the prefixing of file names on output. This is the default when there is only one file to search. |
|
-i Ignore case distinctions in the input files. |
|
-L Suppress normal output; instead print the name of each input file from which no output would normally have been printed. |
|
-l Suppress normal output; instead print the name of each input file from which output would normally have been printed. |
|
-n Prefix each line of output with the 1-based line number within its input file. |
|
-r Read all files under each directory recursively. |
|
-v Invert the sense of matching, to select non-matching lines. |
|
Notes |
If both -H and -h are specified, headers are not displayed. If both -L and -l are specified, -L takes precedence. If both -c and -r are specified, output of count on directories is suppressed. |
Examples | |
To search for user tariq under /etc/passwd using \grep command: \grep tariq /etc/passwd |
|
To force grep to ignore word case i.e mach tariq, Tariq, TARIQ and all other combinations use the -i option: \grep -i "TARIQ" /etc/passwd |
|
To search recursively use the -r option \grep -r "192.168.1.5" /etc/ |
|
To count lines when words are matched use the -c option with \grep Sample File:1>\cat pattern-test.txt Mary had a little lamb Mary fried a lot of spam Jack ate a Spam sandwich Jill had a lamb spamwich \grep -c Mary pattern-test.txt |
|
Grep invert match, use the -v option \grep -v Mary pattern-test.txt |
|
To print the filename for each match together with the matched line, use the -H option: \grep -H Mary *.txt |
|
To suppress the filenames on output, use the -h option \grep -h Mary *.txt |
|
To print the name of files in a directory, which does not match the pattern, use the -L option \grep -L Mary *.txt |
|
To list the name of matching files with the specified pattern use the -l option \grep -l Mary *.txt |
|
To combine grep with other availabe commands in the fluidshell use pipes \cat pattern-test.txt | \grep -h Mary *.txt |
About AquaClusters Privacy Policy Support Version - 19.0.2-4 AquaFold, Inc Copyright © 2007-2017