I mounted a hard drive which was used by Windows on a Linux Machine, Raspberry Pi to be exact.

Trying to delete the recycle bin folder throws this error:

rm: cannot remove '.BIN': No such file or directory

What's the correct way to remove such folder?

  • @harrymc Hidden Windows file is not the same thing as "dotfile" in Linux though. Besides, it's a directory.
    – Tom Yan
    Jul 8 at 10:27

So the issue is that bash, the command shell you are using, interprets any text following a $ as an environmental variable. You can see this if you type the command:

echo $PWD
#outputs on my system: /home/chris

^On most linux systems this prints the variable that describes the present working directory.

When you use double quotes in a bash expression this tells bash in effect 'I want you to interpret everything inside these normally' which in your case means converting environmental variables to their associated values. Since I imagine your environmental for $RECYCLE is not set to anything the value is a zero length string. Therefore the result of your quoted expression is ".BIN". Since .BIN is not a valid file or directory rm will complain.

The correct solution is in bash you want to use single quotes ' around these expressions. This will tell bash to not do environmental variable expansion or other expansions and send the containing text exactly as it appears to the command.

With all that in mind your correct command line expression would be:


Also on another side note rm will probably still complain because if I remember correctly $RECYCLE.BIN is a directory. Without the -r command line option it will say that rm cannot remove the directory.

To read up on more bash/rm/environment variables details type in your console:

man bash
man rm
man environment
  • 2
    Yes, -r will indeed be required.
    – Ramhound
    Jul 7 at 16:14

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.