zeus
4 years ago
3 changed files with 104 additions and 0 deletions
@ -0,0 +1 @@ |
|||||
|
find /usr/share -name "*.py" -type f -executable -exec grep -Hnsw "return" {} \; |
@ -0,0 +1,80 @@ |
|||||
|
Find all files with extension .py and exec permissions, grep only rows that contain *return* word. |
||||
|
|
||||
|
|
||||
|
[source.sh] |
||||
|
---- |
||||
|
find /usr/share -name "*.py" -type f -executable -exec grep -Hnsw "return" {} \; |
||||
|
|
||||
|
|
||||
|
search for files in a directory hierarchy |
||||
|
|
||||
|
-name pattern |
||||
|
Base of file name (the path with the leading directories removed) matches shell pattern pattern. |
||||
|
The metacharacters (`*', `?', and `[]') match a `.' at the start of the base name (this is a |
||||
|
change in findutils-4.2.2; see section STANDARDS CONFORMANCE below). To ignore a directory and |
||||
|
the files under it, use -prune; see an example in the description of -path. Braces are not |
||||
|
recognised as being special, despite the fact that some shells including Bash imbue braces with a |
||||
|
special meaning in shell patterns. The filename matching is performed with the use of the |
||||
|
fnmatch(3) library function. Don't forget to enclose the pattern in quotes in order to protect |
||||
|
it from expansion by the shell. |
||||
|
|
||||
|
type c |
||||
|
File is of type c: |
||||
|
|
||||
|
b block (buffered) special |
||||
|
|
||||
|
c character (unbuffered) special |
||||
|
|
||||
|
d directory |
||||
|
|
||||
|
p named pipe (FIFO) |
||||
|
|
||||
|
f regular file |
||||
|
|
||||
|
l symbolic link |
||||
|
|
||||
|
s socket |
||||
|
|
||||
|
|
||||
|
-exec command ; |
||||
|
Execute command; true if 0 status is returned. All following arguments to find are taken to be |
||||
|
arguments to the command until an argument consisting of `;' is encountered. The string `{}' is |
||||
|
replaced by the current file name being processed everywhere it occurs in the arguments to the |
||||
|
command, not just in arguments where it is alone, as in some versions of find. Both of these |
||||
|
constructions might need to be escaped (with a `\') or quoted to protect them from expansion by |
||||
|
the shell. See the EXAMPLES section for examples of the use of the -exec option. The specified |
||||
|
command is run once for each matched file. The command is executed in the starting directory. |
||||
|
There are unavoidable security problems surrounding use of the -exec action; you should use the |
||||
|
-execdir option instead. |
||||
|
|
||||
|
grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus |
||||
|
(-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints |
||||
|
the matching lines. |
||||
|
|
||||
|
print lines matching a pattern |
||||
|
|
||||
|
-H, --with-filename |
||||
|
Print the file name for each match. This is the default when there is more than one file to |
||||
|
search. |
||||
|
|
||||
|
-n, --line-number |
||||
|
Prefix each line of output with the 1-based line number within its input file. (-n is specified |
||||
|
by POSIX.) |
||||
|
|
||||
|
-s, --no-messages |
||||
|
Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep, |
||||
|
7th Edition Unix grep did not conform to POSIX, because it lacked -q and its -s option behaved |
||||
|
like GNU grep's -q option. USG-style grep also lacked -q but its -s option behaved like GNU grep. |
||||
|
Portable shell scripts should avoid both -q and -s and should redirect standard and error output |
||||
|
to /dev/null instead. (-s is specified by POSIX.) |
||||
|
|
||||
|
-w, --word-regexp |
||||
|
Select only those lines containing matches that form whole words. The test is that the matching |
||||
|
substring must either be at the beginning of the line, or preceded by a non-word constituent |
||||
|
character. Similarly, it must be either at the end of the line or followed by a non-word |
||||
|
constituent character. Word-constituent characters are letters, digits, and the underscore. |
||||
|
|
||||
|
---- |
||||
|
|
||||
|
|
||||
|
|
Loading…
Reference in new issue