pstein
1
Assume I want to remove a whole directory tree beginning with /foo/bar/
The directory or sub-directories may contain files.
The top directory /foo/bar/ itself should not be deleted.
rm -f- r /foo/bar
does not work because it requires a directory tree without files.
How does it work with files inside?
Peter
zaxxon
2
Looks like a typo; just using -r
requires empty directories, but adding the -f
enforces it and it will nor stop for any directories or files inside.
rm -rf /foo/bar/*
# or
cd /foo/bar
rm -rf *
cero
3
In addition to zaxxons solution, if there are hidden files and/or directories in /foo/bar they are not deleted. You need a second run for them:
rm -rf /foo/bar/.*