> I am trying to delete files by piping the output from ls to egrep to rm :
> 
> ls | egrep '(cd|CD)' | rm

> What am I doing wrong?

You're confused about the way rm accepts arguments - you're trying to
pipe input to it on stdin, which doesn't make sense in this context. But
you're close, try this instead:

ls | egrep '(cd|CD)' | xargs rm

BUT this is a very dangerous way to delete things and you really want to
test the output from the first two commands first.

--
Damien Bateman

--
Another exciting Futurama moment :-

Amy: "Bender, your beer belly's so big your door won't even close. And
that doesn't even make sense." 

Reply via email to