0

I mistakenly create ~ in ~/source

sx@ubuntu:~/source$ pwd
/home/sx/source
sx@ubuntu:~/source$ ll
total 440
drwxr-xr-x  3 sx sx   4096 2012-12-06 02:25 ~
drwxr-xr-x  4 sx sx   4096 2012-12-06 02:25 ./
drwxr-xr-x 47 sx sx   4096 2012-12-06 02:26 ../

I don't dare to delete it using command rm ~, because it may lead to deleting all my file in home dir.

2
  • In your case you can use rm -r "./~" but I've posted more general solution.
    – power
    Dec 5, 2012 at 18:43
  • This has been answered before: superuser.com/questions/609362/…
    – fswings
    Apr 16, 2015 at 0:44

2 Answers 2

2

There is general solution to delete files with uncommon names: first you need to know file's inode number, then you can delete it with find command

$ mkdir "~"
$ ls -i
>28972221 ~
$ find -inum 28972221 -delete
1

As always, specify the path.

rmdir ./~