How to pipe list of files returned by find command to cat to view all the files

后端 未结 15 1449
庸人自扰
庸人自扰 2020-12-02 03:44

I am doing a find and then getting a list of files. How do I pipe it to another utility like cat (so that cat displays the contents of all those fi

15条回答
  •  醉酒成梦
    2020-12-02 04:17

    Here's my way to find file names that contain some content that I'm interested in, just a single bash line that nicely handles spaces in filenames too:

    find . -name \*.xml | while read i; do grep '/dev/null; [ $? == 0 ] && echo $i; done
    

提交回复
热议问题