How do I safely delete all files with a specific extension (e.g. .bak) from current directory and all subfolders using one command-line? Simply, I'm afraid to use rm since I used it wrong once and now I need advice.
|
|
||||
|
|
|
You don't even need to use
But use it with precaution. Run first:
to see exactly which files you will remove. Also, make sure that See |
|||||||||||||||||||||
|
|
|||||||||||||||||||||
|
|
First run the command
(or |
|||||
|
|
Deleting files is for me not something you should use
As Flimm states in the comments:
So:
You don't need to make an alias for this, because the As Eliah Kagan makes clear in extensive comments, you can also make this recursive using This command finds and displays all
To delete them, append an
|
|||||||||||||||||||||
|
|
If you want to delete all files of a certain type, but only 1 folder "deep" from the current folder:
-maxdepth 2 because the current directory "." counts as the first folder. |
|||
|
|