Computing.Net > Forums > Unix > How to remove files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to remove files

Reply to Message Icon

Name: rkba2711
Date: May 24, 2006 at 22:55:10 Pacific
OS: Unix
CPU/Ram: RISC
Product: HP/ rp7400
Comment:

Hi,

In a directory in Unix OS. how to remove all files except the files whose name start with x?

regards
Ravi



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: May 25, 2006 at 00:14:32 Pacific
Reply:

find <directory> ! -name "x*" -exec rm -f {} \;
substitute <directory> with the desired directory .


0

Response Number 2
Name: WilliamRobertson
Date: May 29, 2006 at 01:41:26 Pacific
Reply:

In ksh:

rm !(x*)

(test pattern first with ls)

I'm pretty sure bash can do this if you enable an option somewhere, but I can't seem to find it at the moment.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: How to remove files

How to Remove LILO from Windows NT boot www.computing.net/answers/unix/how-to-remove-lilo-from-windows-nt-boot-/2230.html

How to remove files after 6 hours www.computing.net/answers/unix/how-to-remove-files-after-6-hours/7102.html

how to extract files and redirect r www.computing.net/answers/unix/how-to-extract-files-and-redirect-r/4152.html