shell script: delete all directories named directory.# except directory.N
What would be the easiest way in a script that can run in bash (and preferably ksh and csh too) to delete all directories named asdf.# (where # is 1, 2...10...100...1000), except for asdf.N where N is some number?
For example, if i have directories asdf.1 asdf.2 asdf.3, and i want to delete all but asdf.2 Thanks. |
find -type d -a \( -iregex ".*/asdf\..*" -a ! -iregex ".*/asdf\.2" \) -exec rm -rf {} \;
|
This works properly, but gives me these "errors":
find: ./asdf.1: No such file or directory find: ./asdf.3: No such file or directory Is there a way to supress this, or another way to do it that doesn't report any "errors" ? |
Quote:
|
All times are GMT -5. The time now is 07:04 AM. |