I am trying to make a bash install script. One of the tasks it has to do is to remove a certain full directory if it is present. I tried rmdir [location of directory] but it gives an error saying the directory is "not empty, so not removed". I couldn't find anything online about it. That is, I read some articles with no success. How can I make it remove the directory properly?
Asked
Active
Viewed 512 times
-1
Random Linux User
- 81
- 12
1 Answers
1
rmdir only works if the given directory is empty. Directly from the rmdir man page:
"The rmdir utility removes the directory entry specified by each directory argument, provided it is empty."
You should probably be using:
$ rm -rf your_directory
The -r essentially means to recursively remove all files and dirs.
The -f means to remove files without prompting you and ignores file permissions.
Zach Tuttle
- 141
- 3
-
Please, only for completude, explain what -r and what -f does – iuridiniz Dec 23 '21 at 17:04