Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following bash command:

find repo -name '*.c'

What I want to do is use the files returned as arguments to my perl script, so that it's equivalent to running:

perl ./myscript file1.c file2.c file3.c ...

How can I do this?

share|improve this question
Hey, I think you had input confused with arguments (input is generally associated with a program's standard in stream, which is different from its arguments). I updated your question to reflect this based on the answer you selected and your comments on the answers. Feel free to revert the changes if they were incorrect. – Darth Android Oct 17 '12 at 14:22
Thanks, your interpretation is correct. – WonderCsabo Oct 17 '12 at 21:13
up vote 0 down vote accepted


find repo -name '*.c' | xargs perl ./yourscript

This should be the same as

perl ./yourscript file1.c file2.c file3.c ...
share|improve this answer
Thanks, it works. Another issue just came around: my dear users use spaces in file names. How can i wrap every file name with "" before replacing the \n-s to spaces? Sorry for being silly but i'm completely new to bash. EDIT: found answer – WonderCsabo Oct 16 '12 at 17:44

You can try that :

find repository -name '*.c' -exec perl -pe 's:\n: :g' {} +

The delimiter in the substitution is : here, no need to use / both in Perl & sed.

If you prefer a real pipe :

find repository -name '*.c' | xargs cat | perl -pe 's:\n: :g'
share|improve this answer
Added pipe version – Gilles Quenot Oct 16 '12 at 17:37
Okay, but i have a perl script, which i have to provide input like this: ./myscript.perl -args arg file1 file2 How can i pipe my file list to this script? Sorry if the OP was not clear. – WonderCsabo Oct 16 '12 at 17:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.