[LUGSB] David: I need some help on using xargs command

Vacheh David Sardarian vsardari at ic.sunysb.edu
Wed Nov 17 00:43:40 EST 2010


I think writing a script is the best thing to do... because I do have 
mega quantity of files that I have to execute with the script that I 
wrote...

-David.

On 11/17/2010 12:05 AM, Dan Kegel wrote:
> Vacheh David Sardarian<vsardari at ic.sunysb.edu>  wrote:
>> I'm stuck and I was wondering if there's anyone that could help me? Here is
>> the problem.... I have 35 to 50 files in each folder that I have to process
>> using the python script that I wrote. The python script when executes... it
>> asks for a file name to be entered. For example, name.txt and it takes the
>> file "name.txt" and it does something with it and it outputs name_size.txt.
>> The thing is that I have around 35-50 .txt files... and i don't feel like
>> copy and pasting 35-50 times every time I execute my python script.
>
> First off, why not write the python script to take a list of filenames?
> Then you could do
>    foo.py *.txt
> and it would do them all.
>
> But if you want to use xargs, you might try
>    find . -name '*.txt' | xargs foo.py
> Since foo.py only takes one argument, you might need to use -n 1, e.g.
>    find . -name '*.txt' | xargs -n 1 foo.py
> And if you don't want to run it on its output from previous runs,
> filter out the output files with
>    find . -name '*.txt' | grep -v _size.txt |  xargs -n 1 foo.py
>
> Does that help?
> - Dan
> _______________________________________________
> lugsb mailing list
> lugsb at fsl.cs.sunysb.edu
> To unsubscribe from this list, go to:
> http://www.fsl.cs.sunysb.edu/mailman/listinfo/lugsb
>


More information about the lugsb mailing list