Removing a file called ~ [closed]

半世苍凉 提交于 2019-12-02 03:46:37

问题


I accidentally named a file ~ when I was trying to move it to my home directory. And now in my / there is a file called ~ and I have no idea how I would remove it.

How would I remove a file that I accidentally renamed ~?


回答1:


Put the filename in quotes:

rm '~'

You can follow the bash manual:

https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html

If a word begins with an unquoted tilde character (‘~’), all of the characters up to the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. ...




回答2:


You could just use a backslash to remove it.

 rm \~


来源:https://stackoverflow.com/questions/34619406/removing-a-file-called

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!