LinuxShell:为什么零结尾行不能按预期工作?
我读过关于grep的“人”,当我尝试“经典”的工作方式时,而当我尝试使用零结尾行时,它不起作用:LinuxShell:为什么零结尾行不能按预期工作?,linux,shell,command-line,Linux,Shell,Command Line,我读过关于grep的“人”,当我尝试“经典”的工作方式时,而当我尝试使用零结尾行时,它不起作用: /cygdrive/g/eb # find . -type f | grep -E 'pdf$' ./Je_vais_mieux.pdf ./La_delicatesse.pdf ./Femme.pdf ./Souvenirs.pdf /cygdrive/g/eb # find . -type f -print0 | grep -ZE 'pdf$' Binary file (standard inp
/cygdrive/g/eb # find . -type f | grep -E 'pdf$'
./Je_vais_mieux.pdf
./La_delicatesse.pdf
./Femme.pdf
./Souvenirs.pdf
/cygdrive/g/eb # find . -type f -print0 | grep -ZE 'pdf$'
Binary file (standard input) matches
/cygdrive/g/eb # find . -type f -print0 | grep -zE 'pdf$'
Binary file (standard input) matches
/cygdrive/g/eb # find . -type f -print0 | grep -ZzE 'pdf$'
Binary file (standard input) matches
我遗漏了什么?您遗漏了
grep-a
,告诉grep
,它的输入实际上是文本的:
find . -type f -print0 | grep -E -Zz -a 'pdf$'
也就是说,这是一件愚蠢的事情,因为find
可以在没有grep帮助的情况下按后缀过滤自己的输出:
find . -name '*pdf' -type f -print0