This question already has an answer here:

I'm trying to manipulate files in a directory whose filepath includes a directory that starts with "$", for instance:

git rm path/to/file/$dollarsigndirectory/anotherdirectory/file.format

I'm getting the following error:

fatal: pathspec 'path/to/file//anotherdirectory/file.format' did not match any files

EDIT: I've already tried using \$dollarsigndirectory and it simply says there isn't a directory called '\$dollarsigndirectory'

I've tried to troubleshoot but can't figure out why the '$' would make the directory invisible. Thanks!

marked as duplicate by muru, G-Man, Christopher, jimmij, Isaac Apr 2 '18 at 20:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Because $dollarsigndirectory is the value of the shell variable dollarsigndirectory. – muru Apr 2 '18 at 2:23
  • Sorry, I'm relatively inexperienced with terminal. How would I distinguish between the shell variable and the directory when trying to access the filepath in a terminal command? I've tried using '\' before the dollar sign (I edited my question to reflect that) – Dollarsignpredicament Apr 2 '18 at 2:29
  • You can surround the path with single or double quotes so that the $ is not expanded. – Nasir Riley Apr 2 '18 at 2:41
  • Is that directory added to git in the first place? – muru Apr 2 '18 at 2:42
  • @NasirRiley That seems to work, thanks so much! – Dollarsignpredicament Apr 2 '18 at 2:49

You can surround the path with single quotes so that the $ is not expanded.

  • 2
    Single quotes will work for this, but $ expressions are still expanded in double quotes, so they will not work for this. – Gordon Davisson Apr 2 '18 at 3:47
  • True. Double quotes will work if there are other special characters such as ' , or . but not in this case. Edited to correct. – Nasir Riley Apr 2 '18 at 11:50

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