I have the following command taken from here
find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' \;
And i want to turn it into a function along the lines of
pdf_search() { find ./ -name '*.pdf' -exec sh -c 'pdftotext "$1" - | grep --with-filename --label="{}" --color "$@"' \; ; }
I'm not sure how to do this though, i just want to be able to pass an argument to the function to use it such as
pdf_search 'look for this'
using the command as
pdf_search() {
find ./ -name '*.pdf' -exec sh -c 'pdftotext "$1" - | grep --with-filename --label="{}" --color "$1"' \; ;
}
Gives the following error -
I/O Error: Couldn't open file '': No such file or directory.