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

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


I'm assuming the python script and the code that you provided would be 
separate from the script that I wrote... like two separate python script 
files... correct?

Thanks,
David.

On 11/17/2010 12:05 AM, Richard Yao wrote:
> If your python script can take the file name as an argument, you can
> do something along the lines of the following:
>
> for i in $(ls); do echo $i; done
>
> Just replace "echo $i" with the command you want to execute and it
> will iterate across all files in the present working directory.
> Something more fancy that you can do is concatenate lists of
> everything in each
>
> for i in $(cat<(for j in $(ls); do echo $j; done)); do echo $i; done
>
> Note that the "<(for j in $(ls); do echo $j; done)" is a subshell that
> puts data in a temporary named pipe, which is then provided to the cat
> command. You can use as many of these as you want and do all sorts of
> things with them. Under the assumption that your script takes the file
> name as an argument, it is possible to execute your script on all
> files in all directories with a single command.
>
> I hope this is helpful.
>
> On Tue, Nov 16, 2010 at 11:47 PM, Vacheh David Sardarian
> <vsardari at ic.sunysb.edu>  wrote:
>> Hi Everyone,
>>
>> 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. So I
>> heard that there is a xargs command that can be used to pipe a list of file
>> to xargs so that it runs the command on each file... but I have no idea how
>> to do this... the more I search on Google the more confused I get... and its
>> hard for me to understand the man pages...
>>
>> I was wondering if John or anyone in the mailing list can give me a hand to
>> solve the problem that I'm facing right now.
>>
>> Thank you,
>> David.
>> _______________________________________________
>> 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
>>
> _______________________________________________
> 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