Doh!  You're right about there being a big typo in the awk version....

should have been 

ls -1 *March* | awk '{printf(" -f %s\n",$1)}' | xargs rm

As for whether or not the awk is needed.... You may/may not
be right... I can't see much difference one way or the other,
but I'll double check.  In case of doubt, I would do it anyway.
If you DO try it without the awk, you might not need the -1 for
the ls, though, as you said.

Yes, your find was by far the more elegant solution.... I wish I'd
thought of just sending that one first.

find . -name "*March*" -exec rm -f {} \;

is the best solution I see.

Bill

-----Original Message-----
From: Gordon Messmer [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 01, 2000 2:01 PM
To: [EMAIL PROTECTED]
Cc: recipient.list.not.shown; @nswcphdn.navy.mil
Subject: Re: Arguments too long


Ward William E PHDN wrote:
> Or this:
> 
> ls -1 "*March*" | xargs rm -f
> 
> hmmmm... that may not work either, but this DEFINITELY should
> 
> ls -1 "*March*" | awk '{printf(" -f %s\n",$1}' | xargs rm -f

Neither of those will work, because "ls" doesn't do globbing.  The shell
does.  When you type:
ls *March*
"ls" gets the arguments "March1.doc How_to_March.txt Eides_of_March". 
However, when you type:
ls "*March*"
"ls" gets "*March*" as an arguement.  It will tell you there is no such
file.

As for your "awk", I think it's a little too much.  A couple of points: 
AFAICT, there is no difference between "ls" and "ls -1" in this
context.  Awk will produce the same output either way.  It follows that
xargs will behave the same either way. "xargs" will end up executing:
rm -f -f March1 -f March2 -f March 3
So, you've added a bunch of extra -f arguments to the command, but aside
from that, done nothing useful.

Why am I ranting this morning?  All of the solutions I've seen to the
problem of "rm *March*" failing have involved "ls *March*", which will
fail for the same reason that "rm *March*" does.  ;)

Use "find".

MSG


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to