Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I accidentally created a directory who's name begins with the "$" character, and now I can't figure out how to ls its contents or rm -r it altogether.

I've tried quoting the name like this ls "$[dir-name]" as well as escaping the special character like ls \$[dir-name], neither of which worked.

Any tips? Thanks!

share|improve this question
up vote 4 down vote accepted

Using double quotes fails since the shell will still try to expand the variable, but escaping it should work unless there are other characters that may cause an issue as well. Try single quotes.

ls '$foo'
share|improve this answer

Supposing your file is named $file, you can also rm *file. In zsh, you could also rm ?file.

share|improve this answer
think twice before executing rm *file because that will delete all files with filenames ending in "file" – lesmana Apr 24 '11 at 8:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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