rm all except current dir ?
Hi All,
I need to run a script from the same directory that this script deletes files from. But I don't want it to touch the folder that the script is in ? Is there anyway to do this ? (note I have to use rm) MainFolder (containd all folders and files) FolderA (contains my files including the script) FolderB, FolderC ... (Could be any fodlers that I want to delete. Thanks. |
So you have a "MainFolder" that has many files and directories, all of which you want to delete including any number of subdirectories and files contained therein, except for anything in FolderA (and obviously the MainFolder itself)?
You could try something like this: Code:
for i in `find /path/to/MainFolder/* | grep -v "FolderA"`; do rm -rf $i; done |
Thank you. that solved it for me.
|
All times are GMT -5. The time now is 12:03 AM. |