Title.
echo "\*"
has the exact same output as echo "\\*"
, \*
. I am using GNU bash 5.2.15.
I expected echo "\\*"
to output \*
, but I do not know why echo "\*"
did too. To my knowledge it should have gone a bit like this:
- Bash sees:
$echo "\*"
- Bash processes double quotes, leaving the backslash unescaped:
$echo \*
- Bash escapes
*
with backslash:$echo *
- Bash prints
*
.
My suspicion lies in 3. I believe that the backslash does not escape the *
because it is already escaped in 2. Is this correct?
\
is removed only if it was unquoted. In this case it is quoted, so it won't be removed.$
symbols on the front ofecho
? If they're a prompt then your shell won't see that - it printed it for youecho \\\z
output \z?