bash scripting question

Charles Steinkuehler charles at steinkuehler.net
Thu Feb 13 21:25:44 CST 2003


Hal Duston wrote:
> On Thu, 13 Feb 2003, Charles Steinkuehler wrote:
> 
>> ls -1 save* | sed '1,10d' | >> while read FILE ; do
>>    rm -rf $FILE
>> done
>> 
>> This avoids ever expanding the file list completely.
>> 
> 
> Well, if you're going to do this, might as well do
> 
> ls -1 save* | sed '1,10d' | xargs rm -rf
> 
> and save the while loop, and a greatly reduce the number of
> calls to `rm -rf'.

Indeed...xargs would work a lot better.

I tend to forget about things like xargs because I do most of my 
shell-scripting on my single-floppy firewall, where I don't have fancy 
stuff like xargs and have to make due with (ash) shell built-ins. :)

-- 
Charles Steinkuehler
charles at steinkuehler.net




More information about the Kclug mailing list