-a:不要忽略二进制数据;grep原本是搜寻文字文件,若拿二进制的档案作为搜寻的目标,则会显示如下的讯息: Binary file 二进制文件名 matches 然后结束。若加上-a参数则可将二进制档案视为文本文件搜寻,相当于–binary-files=text这个参数。 root@68fc0a9bc6dd:/home/wzm/testgrep# grep
Binary file filename matches 如果此时确实需要对二进制文件进行匹配,可以加 -a 参数,使grep将二进制文件当作文本文件来进行匹配。 使用man命令查看grep参数,可以发现: -a, --text Treat all files as ASCII text. Normallygrepwill simply print ``Binaryfile... matches''iffiles contain binary characters. Us...
--label=LABEL use LABEL as the standard input file name prefix -o, --only-matching show only the part of a line matching PATTERN -q, --quiet, --silent suppress all normal output --binary-files=TYPE assume that binary files are TYPE; TYPE is 'binary', 'text', or 'without-match' -...
Interpret PATTERN as a Perl regular expression. 也就是说-o,只显示匹配行中匹配正则表达式的那部分,-P,作为Perl正则匹配 192.168.0.1 abc@163.com 匹配ABC类IP地址即 1.0.0.1---223.255.255.254 命令(IP):grep -oP "([0-9]{1,3}\.){3}[0-9]{1,3}" file.txt 或grep -E --color "\<([1-...
ENgrep 是 Linux 下非常重要的一个工具,grep 全称是 Global Regular Expression Print,表示全局正则...
[root@www ~]# grep [-acinv] [--color=auto] '搜寻字符串' filename 选项与参数: -a :将 binary 文件以 text 文件的方式搜寻数据 -c :计算找到 '搜寻字符串' 的次数 -i :忽略大小写的不同,所以大小写视为相同 -n :顺便输出行号 -v :反向选择,亦即显示出没有 '搜寻字符串' 内容的那一行! -...
--label=LABEL use LABEL as the standard input file name prefix -o, --only-matching 只显示一行中匹配PATTERN 的部分 -q, --quiet, --silent 不显示所有输出 --binary-files=TYPE 假定二进制文件的TYPE 类型; TYPE 可以是`binary', `text', 或`without-match' -a, --text 等同于 --binary-files...
If TYPE is without-match, when grep discovers null input binary data it assumes that the rest of the 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. When type is ...
grep -[acinv] '搜索内容串' filename-a 以文本文件方式搜索-c 计算找到的符合行的次数-i 忽略大小写-n 顺便输出行号-v 反向选择,即找 没有搜索字符串的行其中搜索串可以是正则表达式!1搜索有the的行,并输出行号$grep -n 'the' regular_express.txt搜 索没有the的行,并输出行号$grep -nv 'the' ...
ex: $ grep -A 1 panda file (从file中搜寻有panda样式的行,并显示该行的後1行) 2. -a或--text grep原本是搜寻文字档,若拿二进位的档案作为搜寻的目标, 则会显示如下的讯息: Binary file二进位档名matches然後结束。 若加上-a参数则可将二进位档案视为文字档案搜寻, 相当於--binary-files=text这个参数。