linux command - query file contains a character

grep command

grep --color=auto -rns "hello world" *

grep command : grep (Globally search a Regular Expression and Print) for filtering / searching the specific character. Regular expressions can be used in conjunction with a variety of command

The string to look : If the search string contains spaces, caused by the need to single and double quotation marks can be used

* : All files in the current directory, you can also write specific directory or file name

Return result : The result is returned in the console, if used in a script, you can search through a successful return 0, 1 search fails to return, file search does not exist, the judge returns 2

Parameters :

-r is this same recursive search -R

-n query result display line numbers

-i ignore case

-s does not display an error message

-w matches whole words only, and not part of the string

The number 'search string' -c statistics of each line found (when there -c -n failure)

-V displays all lines do not contain matching text, reverse lookup 

-l and -L option to display only the matching / non-matching file names

L n have the time and the conflict can only display matching file names

-H output file name -h hidden file name

--color = auto query string can be displayed using different colors

Published 31 original articles · won praise 16 · views 70000 +

Guess you like

Origin blog.csdn.net/SwTesting/article/details/84569330