Help - Search - Members - Calendar
Full Version: The Rm Command
Linuxhelp > Support > Technical Support
chili1000
I want to, in a directory, delete all files but the ones ending with .c
somewhere I read that this line would do it:

rm $(ls -1|grep -v ".c$")

but I just get the following output:

Illegal variable name.

I understand the "ls -1|grep..." part, but not how I redirect that output
to an input for the rm command.

Can anyone out there help me?
jetblackz
Why not this?

rm -f *.c
Joey
rm -rf `ls -l |grep -v .c`

or

ls -l | grep -v .c | xargs rm -rf


should work. try it out on fake shit first though smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.