先用lsof命令配合grep lsof -n|grep lsof(list open files)是一个查看当前系统文件的工具。在linux环境下,任何事物都以文件的形式存在,用户通过文件不仅可以访问常规数据,还可以访问网络连接和硬件;如传输控制协议 (TCP) 和用户数据报协议 (UDP)套接字等,系统在后台都为该应用程序分配了一个文件描述符,该文件描述...
Only the names of files not containing selected lines are written to standard output. Pathnames are listed once per file searched. If the standard input is searched, the string “(standard input)” is written unless a --label is specified. -l, --files-with-matches Only the names of files...
EXAMPLE The following example outputs the location and contents of any line containing “f” and ending in “.c”, within all files in the current di‐ rectory whose names contain “g” and end in “.h”. The -n option outputs line numbers, the -- argument treats expansions of “*g*...
-l, --files-with-matches print only FILE names containing matches -L, --files-without-match print only FILE names not containing matches --label=name set name for standard input --line-buffered use line buffering --line-offsets output line numbers and offsets, not text --locale=locale us...
-i, --ignore-case Ignore case distinctions in both the PATTERN and the input files. (-i is specified by POSIX.) -v, --invert-match Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.) -w, --word-regexp Select only those lines containing matches...
In this example, the output does not include lines containing the plural form servers. Search Subdirectories To recursively search all files, including subdirectories, add the -r operator to the grep command: grep -r phoenix *Copy The system prints matches for all files in the current directory...
min / max sequence numbers: 2 / 9 Inode is Allocated Finding all blocks that might be directories. D: block containing directory start, d: block containing more directory entries. Each plus represents a directory start that references the same inode as a directory start that we found previously...
You can also use the zcat command to display the contents of a gz file and then pipe that output to grep to isolate the lines containing your search string. $ zcat file.gz | grep word-to-search Grep email addresses from a zip file ...
Matching Files Containing String Apart from showing where a specific string occurs in different files, you can also use Grep to create a list of files that contain your target text. This is useful if you want to know if a file contains a particular string but don’t want Grep to print ...
9. To Select only those lines containing matches that form whole words: # grep -w PATTERN # grep --word-regexp PATTERN 10. To Select only those matches that exactly match the whole line: # grep -x PATTERN # grep --line-regexp PATTERN ...