I create a file name :~ on bash shell by accident

scp foo :~

How to delete it?

  • 1
    Is the file called :~ (as in question) or :? (as in title)? – Kusalananda Jun 7 '18 at 7:54

try rm ':?' or rm ":?" or rm :\?

mainly you need to quote the file name either with single quotes or double quotes. Or escape any special characters contains in files name.

some special characters I can count are:


I suggest to use single quotes to prevent deleting a wrong file named my_file instead of $file with rm $file or rm "$file" when file='my_file'

  • 2
    I would also use the -i flag just to make sure you're deleting the proper file. – doneal24 May 29 '18 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.