Operating System - HP-UX
1758616 Members
1867 Online
108874 Solutions
New Discussion юеВ

Excluding Directories from Deletion

 
SOLVED
Go to solution
John Donovan
Regular Advisor

Excluding Directories from Deletion

I see it is possible to exclude one directory from the "rm" command...
rm -rf !(lost+found)

Is it possible to include a second or more directories?

I've tried several combinations but have been unsuccessful.

Thanks,
--donovan
"I have not failed. I've just found 10,000 ways that won't work." - Thomas Edison
2 REPLIES 2
Jeff_Traigle
Honored Contributor
Solution

Re: Excluding Directories from Deletion

Separating with | seems to work on the quick test I just did.

rm -rf !(dir1|dir2)
--
Jeff Traigle
John Donovan
Regular Advisor

Re: Excluding Directories from Deletion

Thanks, I didn't even think about a pipe...
:-)
--donovan
"I have not failed. I've just found 10,000 ways that won't work." - Thomas Edison