(1) find the findcontents in the file content of all files in the current directory (case insensitive, listing the row of the file where findcontents is located) & mdash; suitable for the current directory, the number of files and directories is relatively small. if too many contents are listed after searching, it will lose...
(1) find the findcontents in the file content of all files in the current directory (case insensitive, listing the row of the file where findcontents is located) -- The number of files and directories in the current directory is relatively small. if too much content is listed after searching, it will lose the meaning of searching.
Grep-rin findcontents *
(2) if too much content is listed after searching, use the following command (only list the number of occurrences of findcontents in the file ):
Grep-ric findcontents * | grep-v: 0
(3) If you do not know the directory where the file is located, you need to search for the entire hard disk space in the root directory ), however, some files (bin, sbin, boot, dev, initrd, and lib) in the root directory have no search value, so they must be excluded from the search scope.
# Cd/
Grep-rin findcontents 'ls | grep-VE' bin | boot | dev | initrd | lib''
------------------------------------------
-I, -- ignore-case
-N, -- line-number
-C, -- count
-R, -- recursive
-V, -- invert-match
-E, -- extended-regexp
-E PATTERN, -- regexp = PATTERN
Use PATTERN as the pattern; useful to protect patterns beginning -.
Note: n becomes invalid when c exists.
Find the *. conf file containing the alias string
Find/-name "*. conf" | xargs grep "alias"
1. grep-R-l can also be implemented, but pipeline | is more efficient than simply using grep complex parameters.
2. xargs is used to expand the result obtained by find and use it as the grep parameter.
Author: "Learning linux"