我希望根据我所做的 grep 搜索应用一些命令,grep -l "If you wish to distribute" *.pdf
并且我看到了我想要处理的文件,但是使用以下 bash 脚本,这些文件没有被处理:
#!/bin/bash -x
text1="If you wish to distribute" #Science papers
# Originally: grep -l "text1" \*.pdf |
grep -l "$text1" *.pdf |
while IFS="" read -r -d "" file; do
noext="${file%\.*}"
pdftk "$file" cat 2-end output "$noext".tmp
mv -f "$noext".tmp "$file"
done
输出是
+ IFS=
+ grep -l 'If you wish to distribute' project_latex.pdf 'Science 2003 Metapopulation Persistence with Age-Dependent Disturbance or Succession.pdf' 'Science 2006 A Keystone Mutualism Drives Pattern in a Power Function.pdf' short-math-guide.pdf Test.pdf
+ read -r -d '' file