Need help on Linux rm command
Need help on Linux rm command
I want to recursively delete all files ending with '~', starting in a folder named './src'. I tried 'rm -r src/*~', but this only deleted the targetted files in ./src, not in the sub folders of ./src.
Re: Need help on Linux rm command
I think it should have been " rm -r ./src/*~ " but you can also use the -v for verbose and it will spell what it is doing and when.Diedel wrote:I want to recursively delete all files ending with '~', starting in a folder named './src'. I tried 'rm -r src/*~', but this only deleted the targetted files in ./src, not in the sub folders of ./src.
OPTIONS
Remove (unlink) the FILE(s).
-d, --directory
unlink FILE, even if it is a non-empty directory (super-user
only)
-f, --force
ignore nonexistent files, never prompt
-i, --interactive
prompt before any removal
-r, -R, --recursive
remove the contents of directories recursively
-v, --verbose
explain what is being done
personally i don't have much EXP points in Linux, but
can't you:
- first temporarily move (to somewhere secure) all of the directorys you don't want to delete files from? (perhaps using a visual file manager that can sort things alphabetically and select directorys with a drag-box)
- run this from the original directory 'rm -r *~'
- then move those other folders back
can't you:
- first temporarily move (to somewhere secure) all of the directorys you don't want to delete files from? (perhaps using a visual file manager that can sort things alphabetically and select directorys with a drag-box)
- run this from the original directory 'rm -r *~'
- then move those other folders back
- KompresZor
- DBB Captain
- Posts: 919
- Joined: Wed Jul 31, 2002 2:01 am
- Location: Clearfield, Pennslyvania
First, the test...
make sure these are the right files
then....
to remove the files
rm -r is to remove a directory with files in it since \"rmdir\" will not unlink a directory unless it is empty.
Code: Select all
locate *.~¦grep /path/to/scr
then....
Code: Select all
rm 'locate *.~¦grep /path/to/scr'
rm -r is to remove a directory with files in it since \"rmdir\" will not unlink a directory unless it is empty.
- FunkyStickman
- DBB Ace
- Posts: 309
- Joined: Wed Apr 20, 2005 2:26 pm
- Location: 'Nawlins
Re: Need help on Linux rm command
Try doing "rm -r ./src" I don't know if that may work.Diedel wrote:I want to recursively delete all files ending with '~', starting in a folder named './src'. I tried 'rm -r src/*~', but this only deleted the targetted files in ./src, not in the sub folders of ./src.
Well seeing as you're oh so knowledgable in the world of Linux, having read the manpage for rm three times, you'd obviously know that wildcard expansion is done by the shell, not the command it is passed to. And therefore, \"./src/*~\" expands to every filename in ./src that ends with ~. But like I said, being the absolute fscking genius you are you obviously knew that already.
[spoiler]`rm ./src/*~ ./src/*/*~` you tool.[/spoiler]
[spoiler]`rm ./src/*~ ./src/*/*~` you tool.[/spoiler]