0

I was going through my desktop in Linux and I noticed a list of files that were not on my desktop. They are Microsoft word(.doc & .docx) files that exist on my computer elsewhere. For some reason they are showing up on my desktop(in UNIX environment). They start with '~$' and the first two letters of file names are cut off. For example if the file name is filename.docx, it would show as ~$lename.docx. How can I remove these files?

  • Did you previously have those Word documents on your desktop? – user1686 Jul 22 '18 at 6:55
  • @grawity Yes it is possible that some of them have been on my desktop in the past, some of them are over two years old. From my research, I have seen that Microsoft Word stores backup hidden files like these for emergency. It just bugs me that they are showing up in my UNIX environment. – Aladdin Al-Khatib Jul 22 '18 at 7:15
  • @Scott I have tried doing $ rm ~$lename.docx but I got a message saying rm: No such file or directory. The same with $ rm filename.docx and $ rm lename.docx – Aladdin Al-Khatib Jul 22 '18 at 7:18
  • If you copied your entire desktop from a Windows system, why wouldn't they show up? – user1686 Jul 22 '18 at 7:24
3

With rm ~$lename.docx, the shell sees $lename and tries to expand it to the contents of the likely non-existent variable lename, so the command ran is actually something like rm ~.docx. You'll have to quote it so that the shell doesn't try to do that:

rm '~$lename.docx'

Alternatively, if you have multiple such files, you can use shell globbing (wildcards), assuming all such filenames begin with ~$ and end with docx:

rm ~$*.docx
| improve this answer | |
  • Yes, thank you. It worked by doing rm *.docx and rm *.doc, it didn't need the ~$ for some reason. Thanks alot! – Aladdin Al-Khatib Jul 22 '18 at 7:27
  • @AladdinAl-Khatib without the ~$, if you had a normal lename.docx file, that would have been deleted too. If you didn't have any of those, *.docx is fine. – muru Jul 22 '18 at 7:29
  • @AladdinAl-Khatib: The ~$ is not a magic prefix; it is just part of the actual file name. It doesn't affect the way wildcards work. – user1686 Jul 22 '18 at 9:54

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.