【发布时间】:2016-03-29 07:43:10
【问题描述】:
我有以下命令取自 here
find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' \;
我想把它变成一个函数
pdf_search() { find ./ -name '*.pdf' -exec sh -c 'pdftotext "$1" - | grep --with-filename --label="{}" --color "$@"' \; ; }
我不知道该怎么做,我只是想能够传递一个参数 到函数来使用它,例如
pdf_search 'look for this'
使用命令作为
pdf_search() {
find ./ -name '*.pdf' -exec sh -c 'pdftotext "$1" - | grep --with-filename --label="{}" --color "$1"' \; ;
}
给出以下错误 -
I/O Error: Couldn't open file '': No such file or directory.
【问题讨论】: