![]() But if needed, you could add something like | sed 's/ /\\ /g to the end of the command substitution pipeline to escape the spaces. You can search the strings is a pdf with grep like this: ls dirwithpdfs/.pdfxargs stringsgrep 'keyword' Or you can use the pdf2text command on pdf's and then search result with grep. Personally, I haven't bothered figuring out a workaround for these two failure modes because I always run such 'match action' commands in two stages (so I always know whether there were zero matches, and the action can therefore be skipped) and I scrupulously avoid filenames with spaces in them. Pdf is a binary format, that's why searching it with grep is not that helpful. Files with spaces in the name will cause problems.The pathological case where no files match the pattern will result in a somewhat cryptic error saying: mv: missing destination file operand after './destination'.2.1.1 Generic Program Information-help Print a usage message briefly summarizing the command-line options and the bug-reporting address, then exit. Note that this will fail under two circumstances: Several additional options control which variant of the grep matching engine is used. Of course, you can re-type the whole command instead, if you prefer: $ mv -i $(pdfgrep -i "Fatima Alves" *.pdf | cut -d: -f1 | sort -u). You can get the list of matching filenames using: $ pdfgrep -i "Fatima Alves" *.pdf | cut -d: -f1 | sort -uĪfter running the above command and ensuring it generates the expected output, you can use Bash command substitution ( $()) and history expansion ( !!) to quickly re-run it and move the files, like so: $ mv $(!!). ![]() I find it easiest to build up the command incrementally.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |