1

I have a script which can take one file name at a time and I want to run it for many files in a folder. So, I want to pipe the output of:

find . -iname '*.m' 

to my script but one line at a time.

1 Answer 1

4

You are looking for xargs.

find . -iname '*.m' | xargs yourscript

xargs reads items from the standard input, delimited by blanks or newlines, and executes the command (default is /bin/echo) one or more times with any initial-arguments followed by items read from standard input.

1
  • Awesome. This worked for me. My script also took some other options, so I did: find myfolder/ -iname '*.js' | xargs ./doMoreStuff.js -r Commented Oct 26, 2013 at 0:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.