Is it possible to remove all files & folders in a directory without using their names
For example, my mnt directory consists of two folders, with 16 files in each, and 48 files.
|
Yup. Use the "*" character and the -r switch for the rm command. man rm
|
Usually /mnt directory is a location to mount things, be sure you double check what you delete here, at it can't be undone
|
Code:
find /mnt -type f -exec rm '{}' \; |
I am not very sure if I get it correctly but if you want to delete everything inside /mnt
Code:
#rm -rf /mnt/* |
rm -rf would be the right thing for usual directories but it is surely not recommended for /mnt. You would generally want to unomount things that are present under /mnt, so please be careful before you do that.
|
IOW, given -r = recursive & -f = force, be VERY careful with that ;)
|
Did this once... deleted entire external HDD which was mounted very, very fast...
|
When I was first getting started with Linux I once ran "rm -fr *" by accident when I was root in /
After re-installing the OS, I never made that mistake again. |
All times are GMT -5. The time now is 08:46 AM. |