How to escape parenthesis in bash rmdir?
You can use \
to escape any single character, (
and )
included as you already do with spaces. While it works, it can be cumbersome if you have lots of characters/spaces to escape.
A faster alternative is to use single quotes ('
) to escape the whole string, i.e. something like:
rm -rf '10.2 (14C92)'
Please keep in mind that '
escape everything, so use it with care if you need, for example, variable expansion inside the quotes. That said, using double quotes works for escaping spaces and parentheses, also:
rm -rf "10.2 (14C92)"
Also, based on your question, you try to use rmdir
. rmdir
works only for empty directories and it doesn't have -r
and/or -f
flags:
NAME rmdir - remove empty directories
SYNOPSIS rmdir [OPTION]... DIRECTORY...
DESCRIPTION Remove the DIRECTORY(ies), if they are empty.
You'll want to use rm -rf
.
If 10.2 (14C92)
is indeed empty, a simple
rmdir '10.2 (14C92)'
would do.
Escaping is done by bash
itself, so it works for every command. In other words, it's bash
which decides what to pass to the command, based on its own parsing rules, the command then acts on the arguments after bash
has parsed them.