Axe*_*auf 85
您grep无论如何都可以使用来搜索文件 - 它并不真正关心输入文件是否真的是文本。来自“男人 grep”:
-a, --text
Process a binary file as if it were text; this is equivalent to the --binary-files=text option.
--binary-files=TYPE
If the first few bytes of a file indicate that the file contains binary data, assume that the file is
of type TYPE. By default, TYPE is binary, and grep normally outputs either a one-line message saying
that a binary file matches, or no message if there is no match. If TYPE is without-match, grep assumes
that a binary file does not match; this is equivalent to the -I option. If TYPE is text, grep
processes a binary file as if it were text; this is equivalent to the -a option. Warning: grep
--binary-files=text might output binary garbage, which can have nasty side effects if the output is a
terminal and if the terminal driver interprets some of it as commands.
Run Code Online (Sandbox Code Playgroud)
请在第二段末尾标出警告语。您可能希望将 grep 中的结果重定向到一个新文件中,并使用 vi/less 进行检查。
小智 5
您可以使用这三个命令:
grep -a <sth> file.txt
cat -v file.txt | grep <sth>
cat file.txt | tr '[\000-\011\013-\037\177-\377]' '.' | grep <sth>
| 归档时间: |
|
| 查看次数: |
226086 次 |
| 最近记录: |