我有一个命令,我想在我的.bashrc中有一个函数。Bash语法字符串插入
从命令行
find . -name '*.pdf' -exec sh -c 'pdftotext {} - | grep --with-filename --label={} --color "string of words" ' \;
将在当前目录中的任何PDF找“字的串”。
尽管一个小时的最好的部分,我认真无法获得作为一个字符串变量工作“字样的字符串” - 即
eg="string of words"
find . -name '*.pdf' -exec sh -c 'pdftotext {} - | grep --with-filename --label={} --color $eg ' \;
这显然是行不通的,但我已经尝试了所有"/'/\
与echo
黑客,数组扩展,但没有运气。我相信它是可能的,我相信它很容易,但我无法实现它的工作。
你可能有乐趣写这个,但是你有没有考虑正装[pdfgrep](HTTPS ://gitorious.org/pdfgrep)? – kojiro