PDA

View Full Version : directory manipulation



corefile
November 27th, 2007, 05:35 AM
I have a directory, lets day /dir1 and in /dir1 I have several other directories, and in those directories I have several files, and I want to delete all the files ending in .deleteme in all the directories under /dir1
is this possible with the "rm" command?

ThinkBuntu
November 27th, 2007, 05:51 AM
Here's how I'd do it with my basic Bash shell knowledge:


$ rm dir1/*.deleteme
$ rm dir1/*/*.deleteme


And so on. Use more */ for each level of directories.

volanin
November 27th, 2007, 05:54 AM
$ find /dir1 -name '*.deleteme' -exec rm {} \;

corefile
November 27th, 2007, 05:59 AM
$ find /dir1 -name '*.deleteme' -exec rm {} \;

If I do that from the command line this is what I get

find: missing argument to `-exec'

*edit* wait I found the problem, I didn't have a space after {}

volanin
November 27th, 2007, 06:03 AM
If I do that from the command line this is what I get
find: missing argument to `-exec'

You probably mistyped it.
I tested it here, and it is ok.
Please copy and paste, and test again!
:)

corefile
November 27th, 2007, 06:08 AM
worked! Thanks for the quick response