Reputation: 615
By mistake while using vim
when exiting using :wq!
I type an extra character (~
) this created a directory named ~
; however if I cd
into it it would take me to the current user's home
. How can I remove this directory without actually remove my home directory?
Upvotes: 3
Views: 675
Reputation: 19
All of the recommended ways didn't help in my case. So I did:
rm -rf ./'~'
and it helped to get rid of "~" directory in my user dir.
Upvotes: 1
Reputation: 615
It can be solved using rm -rfi ./\~
, which explicitly specifies the current directory.
(*) Similar question already ask here (thanks @AvihooMamka)
Upvotes: 3
Reputation: 655
Just quote the ~
. Use rmdir
, not rm
, to be safe (rmdir
will only remove an empty directory, so won't get rid of your home directory even if you mess it up).
$ mkdir '~'
$ ls -la '~'
total 16
drwxr-xr-x 2 me users 4096 Apr 20 13:20 .
drwxr-xr-x 97 me users 12288 Apr 20 13:20 ..
$ rmdir '~'
$ ls -la '~'
ls: cannot access ~: No such file or directory
$
Upvotes: 4