I created a directory named $pattern and now when ever i try to remove it, it says pattern: Undefined variable.I have tried:$ rm -r $pattern$ rm -rf $pattern$ rm $ option[value='2016']
How to remove a folder that starts with $?
shell;quoting;filenames
$, space, ' and [ are special characters in most shells. To remove their special meaning, you have to use the quoting mechanisms of the shell.The quoting syntax varies very much with the shell.In all shells that I know, you can use single quotes to quote all characters but single quote, backslash and newline (in Bourne-like shells, it does quote the last two as well, except in backticks for \ in some).rm -r '$pattern'Should work in most common shells.rm -r \$patternWould work (except inside backticks for Bourne-like ones) in all shells but those of the rc family.Same for:rm \$option[value='2016']In rc-like shells, you'd use:rm '$option[value=''2016'']'