[clug] Two (perhaps simple) shell questions.
Andrew Janke
a.janke at gmail.com
Tue Aug 18 04:20:45 MDT 2009
On Tue, Aug 18, 2009 at 11:39, Mark Triggs<mark at dishevelled.net> wrote:
>> for i in `ls *.mnc`;
>> do
>> do8ofthisatonce <program> $i $i.out
>> done
>
> xargs will do this for you. Something like:
> ls *.mnc | xargs -I'{}' -P 8 program {} {}.out
Thanks Mark, I knew that one day I should learn xargs.. ;) Still
while this will work in most of the things I do xargs doesn't seem to
allow multiple commands? ie (for arguments sake):
for i in `ls *.mnc`;
do
var=`basename $i`
do8ofthisatonce <program> $var $i.out
done
If the answer is "can't be done" then so be it. :) I guess in this
case I could make a quick shell script and call that using xargs but
that sort of spoils the fun.
ta
a
PS: perl -pe 'chop if !($. % 2)' < myfile (yes only one less
character but it seemed an obvious start).
More information about the linux
mailing list