How do I include a pipe | in my linux find -exec command?

后端 未结 6 665
情深已故
情深已故 2020-11-28 17:51

This isn\'t working. Can this be done in find? Or do I need to xargs?

find -name \'file_*\' -follow -type f -exec zcat {} \\| agrep -dEOE \'grep\' \\;
         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 18:28

    I found that running a string shell command (sh -c) works best, for example:

    find -name 'file_*' -follow -type f -exec bash -c "zcat \"{}\" | agrep -dEOE 'grep'" \;
    

提交回复
热议问题