Removing a Directory from the Terminal without deleting each file or folder
How can I delete a folder without deleting each file or folder via terminal?
So let's say I would want to delete the folder
which has 230 files...
How can I delete the folder from the terminal?
I do not want to be prompted to delete each file or folder, yet, delete the complete folder.
Su to root, then give this command:
rmdir --ignore-fail-on-non-empty <dirname>
where <dirname> is the name of the directory to remove.
Or, you could try: rm -dR <dirname> (-d works only for the root user).
-d remove the directory even if it isn't empty (root user only)
-R recursive drill down through the directory.
Or (slightly shorter)
rm -rf /home/username/test
Thank You. You were all very helpful.
Next time, I'll have to do a man on rmdir. I did not see anything on that, though.
Thanks, once again. :D :D :) :) :)
rm -fr / home/username/test
notice the accidental space between / and home (which the shell will interpret as "remove the root directory ( / )), if you accidentally do this, say goodbye to your entire filesystem.
|All times are GMT -5. The time now is 12:28 PM.|