-   Linux - General (
-   -   file contents to command line args (

hawkmauk 11-21-2006 12:49 PM

file contents to command line args
Hi all,

im trying to send the contents of a file (a list of files) to the command line as arguments for a script, I thought I could get away with the following without success

myscript destfile <myfiles.txt
cat myfiles.txt | myscript destfile [the list of files as input files to the script piped here]

I have some scripting experience and could get around this by creating a script, loading the filenames into an array and then executing the script but was hoping someone could help me keep it simple.


matthewg42 11-21-2006 01:04 PM

xargs is what you want.

hawkmauk 11-21-2006 01:19 PM

Never come across xargs before, many thanks to you sir!

matthewg42 11-21-2006 01:27 PM

Yeah, it's super-useful, especially combined with find. I discovered it several months after writing my own program to do more or less the same thing. I didn't know whether to laugh or scream. :D

All times are GMT -5. The time now is 12:14 AM.