removing a directory

Hello all,

I have a directory (in the home directory) that contains a directory entry ~. How can I remove that? If I do "rm -rf ~", obviously it will be removing the home directory.

I am not in the home directory, instead I am in some other directory (I am in ~/docs) in the home directory.
 
If the directory is empty use rmdir from the directory above. if not use rm -r directory without a slash again from the directory above the one you want to delete.

Btw. you cannot remove your home directtory except if you are root. You only by default have the rights to directories inside /home/user
 
If the directory is empty use rmdir from the directory above. if not use rm -r directory without a slash again from the directory above the one you want to delete.

Btw. you cannot remove your home directtory except if you are root. You only by default have the rights to directories inside /home/user
But you can wipe out everything in it. That is dangerous.
 
Find some internet resource that explains how quoting and globbing in the shell works. The answer will depend on what shell you are using, so find one that matches your shell. The answer Emrion gave you was a step in that direction: the "\" backslash before the * or ? means that the shell will not interpret the "?" character. But a more general answer is that (depending on the shell), the following would also work:
Code:
rm "~"
 
Another way of doing it is to use find along with exec and its inum.
To find out what inum that "~" has (assuming its under /home/user) you can do ls -lai /home/user.

To make sure you have a proper one you can do a ls on it first: find /home/user -xdev -inum <INUM> -exec ls -lad {} \; Once you confirm it's OK you can proceed: find /home/user -xdev -inum <INUM> -exec rm -rf {} \;

For those who like midnight commander ( I do ) you can use that also to do quick and safe removal.
 
Yes. Always have backups of important data. And you asked for how to delete things. If you take care, it is mostly not dangerous, if you know what you are doing, If not you might learn something :)
First thank you all.

I have backups too. Did that mistake when first installed the system, now keeping backups all the time.

Thanks again.
 
Back
Top