How do I use a pipe in the exec parameter for a find command?

前端 未结 6 2037
孤街浪徒
孤街浪徒 2020-12-13 01:44

I\'m trying to construct a find command to process a bunch of files in a directory using two different executables. Unfortunately, -exec on find doesn\'t allow

6条回答
  •  一生所求
    2020-12-13 02:02

    A slightly different approach would be to use xargs:

    find /path/to/jpgs -type f -print0 | xargs -0 jhead -v | grep 123
    

    which I always found a bit easier to understand and to adapt (the -print0 and -0 arguments are necessary to cope with filenames containing blanks)

    This might (not tested) be more effective than using -exec because it will pipe the list of files to xargs and xargs makes sure that the jhead commandline does not get too long.

提交回复
热议问题