mistux Site Admin
![](images/avatars/gallery/Miscellaneous/pc_user.gif)
Joined: 25 Jun 2004 Posts: 1042 Location: South Bend, Indiana USA
|
Posted: Thu Mar 27, 2008 2:05 pm Post subject: Delete files |
|
|
List files with extension .doc in tesdir1 + subdirs:
Quote: | ix:~$ find ./testdir1 -name "*.doc" -exec ls {} \;
./testdir1/testdir2/file2.doc
./testdir1/file1.doc |
Remove those files:
Quote: | nix:~$ find ./testdir1 -name "*.doc" -exec rm -i {} \;
rm: remove regular empty file `./testdir1/testdir2/file2.doc'? y
rm: remove regular empty file `./testdir1/file1.doc'? y |
the -i switch to rm makes it ask for confirmation; without it, it would just delete;
rm -r is apparently only to remove directories (+ their contents), not individual files within them, that is maybe why the combination -r and *.doc doesn't work
-r, -R, --recursive
remove directories and their contents recursively |
|