Tag Info

New answers tagged


The rm command refuses to delete the directory by the '.' name. If you instead use the full path name it should delete the directory recursively. It is also possible to delete the directory if it is the current directory. [testuser@testhost] /tmp$ mkdir ff [testuser@testhost] /tmp$ cd ff [testuser@testhost] /tmp/ff$ touch a b c [testuser@testhost] ...


You cannot remove the current directory because then the current directory would become invalid. First, change out of the directory you want to remove (e.g. cd ..) and then remove the desired directory using its full or relative pathname from outside.


The rm -R will actually delete all the files (if it has enough permissions). If you want to leave only the currently opened files, you can check with lsof +D /srv/log/prod/dms/: it will list all the files located under /srv/log/prod/dms/ and that are currently opened. Be careful, to script that, you should be sure that your daemon keeps its files handlers ...


The top-voted answer (http://unix.stackexchange.com/a/161772/88983) in the question you linked to says the following: The order of traversal is unpredictable. (...) The order of traversal isn't something you can rely on. So I would say you generally cannot know for sure whether rm deleted items in dir/dir2. What you could do, however, is run rm in ...


AFAICT, no. The problem is that the gzip process will create a new file and will free the previous (the unzipped) one, including a removal from the directory. If no other hard-link in the filesystem is pointing to the file it will get lost once the last file descriptor refering to it is closed. For the future you'd be advised to synchronize the access to ...


man rm (at least on Ubuntu ... my Solaris box is not plugged in) tells me this: To remove a file whose name starts with a '-', for example '-foo', use one of these commands: rm -- -foo rm ./-foo


Try: rm -- -Insi or: rm ./-Insi


user@host:~$ rm --help Usage: rm [OPTION]... FILE... Remove (unlink) the FILE(s). -f, --force ignore nonexistent files and arguments, never prompt -i prompt before every removal -I prompt once before removing more than three files, or when removing recursively. Less intrusive ...


Find, grep and xargs combination find /var/www/ -maxdepth 1|grep -v wp|xargs rm -rf And can be convert into bash file, for more generalized purpose. #!bash # $1 -- directory # $2 -- Exception filename or directory name find "$1" -maxdepth 1|grep -v "$2"|xargs rm -rf


You can read Michael Homer's answer to know the reason. To remove all things in /var/www exclude wp, POSIXly: find /var/www -path /var/www/wp -prune -o ! -path /var/www -exec rm -rf {} +


If you're running bash ≥4.3, then if you have backups, now would be a good time to find them. I assume you're using Bash. The !(...) filename expansion pattern expands to every existing path that doesn't match the pattern at the point it's used. That is: echo rm -f !(/var/www/wp) expands to every filename in the current directory that isn't ...


One approach would be to boot from some other media, such as CD or USB/SSD, so you don't have to deal with the operating system fighting against the rm.  Possibilities include any live CD that includes a shred capability, or Darik's Boot and Nuke (DBAN). I have no association with DBAN.  I have colleagues who use it.


If you want to delete everything on the partition (as I assume from you saying "delete the whole root") you can run shred /dev/sdXY where sdXY is the device you want to wipe.


Instead, you can rename the current directory to DirX_OLD , create a new directory with the name DirX and move all the required files from DirX_OLD to DirX. After copying the files you can delete DirX_OLD


I would suggest considering a different tool. The 'find' command is very powerful and once you get past some of the syntax rules, easy to use. Example: find /directory -name pattern -perm g=w -exec /bin/rm {} \; This will search for all files and sub folders under /directory that have the group permission of 'write' (logic match to 0020 octal chmod ...

Top 50 recent answers are included