rm -rf . does not delete content of the dir
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
coreutils (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Command rm -rf .
writes:
rm: cannot remove directory: ‘.’
That is OK. But it does not delete the content of the dir ‘.’. Command rm -rf * is not the alternative because
1) it does not include hidden files/directories,
2) number of files could exceed max command line length.
Alternative is: find . -delete, but I vote for repairing the rm command.
Commands to reproduce:
mkdir tmp_rm_test
cd tmp_rm_test
echo a>.a
mkdir b
ls -A
rm -rf .
ls -A
find . -delete
ls -A
cd ..
rmdir tmp_rm_test
ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: coreutils 8.20-3ubuntu5
ProcVersionSign
Uname: Linux 3.11.0-
ApportVersion: 2.12.5-0ubuntu2.2
Architecture: i386
Date: Tue Mar 25 09:57:39 2014
EcryptfsInUse: Yes
MarkForUpload: True
SourcePackage: coreutils
UpgradeStatus: Upgraded to saucy on 2013-10-24 (152 days ago)
This bug is also in POSIX:
http:// pubs.opengroup. org/onlinepubs/ 9699919799/ utilities/ rm.html
If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands.
But the paragraph is not considering -r and -f options.