您遇到的问题是-被视为非单词字符,因此aide其中的字符串aide-被视为单词。从man grep: -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 constituen...
grep 命令最基本的用法是在文件中搜索字符串(文本)。 For example, to display all the lines containing the string bash from the /etc/passwd file, you would run the following command: 例如,要显示/etc/passwd 文件中包含字符串 bash 的所有行,可以运行以下命令: grep bash /etc/passwd 1. 输出应该是...
grep的手册页显示了关于-w开关的以下内容: -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 ...
-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...
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...
For example, to display all the lines containing the string bash from the /etc/passwd file, you would run the following command: 例如,要显示/etc/passwd 文件中包含字符串 bash 的所有行,可以运行以下命令: 代码语言:javascript 复制 grep bash/etc/passwd ...
-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...
This command displays the line containing the string plus 4 lines of text after theensstring in theifconfigcommand.Output Conversely, in the example below, the use of the -B flag will display the line containing the search string plus 3 lines of text before theetherstring in theifconfigcomma...
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 ...
The exit status is 0 if selected lines are found, and 1 if not found. If an error occurred the exit status is 2. 即,grep 命令在所给文件中查找特定模式的字符串,可以提供多个文件名,在多个文件中查找。 如果没有提供文件名,则读取标准输入。