Have a file named ~ (tilde) in my home-directory
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind
--
Chapters
00:00 Question
00:24 Accepted answer (Score 58)
00:51 Answer 2 (Score 52)
01:10 Answer 3 (Score 20)
01:46 Answer 4 (Score 0)
02:19 Thank you
--
Full question
https://superuser.com/questions/609362/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #bash #filesystems
#avk47
ACCEPTED ANSWER
Score 58
The pretty much ultimate solution when it comes to files that can't be deleted by normal means:
ls -il
The first column will show the inode number of the files.
find . -inum [inode-number] -exec rm -i {} \;
This will delete the file with the specified inode-number after verification.
ANSWER 2
Score 52
You should be able to refer to that file as ~/~
(without quotes) because tilde-expansion only applies the the tilde (~
) at the very beginning of the word.
ANSWER 3
Score 20
Quote it (rm '~'
) or escape it (rm \~
).
It's always either of those (also for e.g. $
), or add --
to prevent the file name from being interpreted as argument: rm -- -i
removes the file named -i
; also useful for rm -- *
when you want to delete all files in the current directory: No accidental rm -f *
just because a file is named like that.
ANSWER 4
Score 1
Just to be safe I tried this in mac catalina:
mv '~' '~_bkp'
you can change directory to check the contents
cd '~_bkp' ls
If its empty simply 'remove'
rm -rf '~_bkp'
'rmdir' can be used too to remove the empty directory