Search of files by means of keywords with a formatted output
I'd like to find any kind of file by means of keywords and a formatted output, so I'm trying to use the command " awk
, but I receive this error message:
% find . -type f -exec grep -if /home/peppespe/Documents/1265/keywords.txt '{}' ';' -exec ls -laith '{}' ';' -exec md5sum '{}' | awk '{ print "md5 = " $1 }' ';' -exec sha1sum '{}' | awk '{ print "sha1 = " $1 }' ';'
find: manca l'argomento per «-exec»
awk: linea progr.:1: fatale: non riesco ad aprire file `;' in lettura (File o directory non esistente)
awk: linea progr.:1: fatale: non riesco ad aprire file `;' in lettura (File o directory non esistente)
You're trying to use pipes in the argument to -exec, but they're parsed by the shell prior to calling find. The result is that you're calling awk with ';' as an argument (and it thinks that's a file to open).
Rather than a long chain of -exec, you might want to output a list of files from grep and proceed from there. Something like this (untested)
grep -rifl keywords.txt | while read x; do
echo "$x md5=$(md5sum $x) sha1=$(sha1sum $x)"
done
That's a bit different formatting from what you're doing, but maybe you can work with it from there. :-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.