How do I apply a shell command to many files in nested (and poorly escaped) subdirectories?

后端 未结 6 1620
别跟我提以往
别跟我提以往 2020-12-06 03:31

I\'m trying to do something like the following:

for file in `find . *.foo`
do
somecommand $file
done

But the command isn\'t working because

6条回答
  •  庸人自扰
    2020-12-06 03:54

    find . -name '*.foo' -print0 | xargs -0 -n 1 somecommand
    

    It does get messy if you need to run a number of shell commands on each item, though.

提交回复
热议问题