I'm trying to enter some ascii word art into my shell script and I'm using two backslashes (\\) together I want echo or printf to print both these backslashes together. Is there something I can put after echo or printf to make them literally print every character within the double quotes (")?
for example I want:
echo -something "
__ __ __ __
\\ // \\ //
\\ // \\ //
\\// \\//
"
to print
__ __ __ __
\\ // \\ //
\\ // \\ //
\\// \\//
Exactly how it is.
Single quotes are your friend; backslash is just an ordinary character inside a single-quoted string. So is every other character except single-quote itself.
echo '
__ __ __ __
\\ // \\ //
\\ // \\ //
\\// \\//
'
If you needed single quotes in the single-quoted output, you have to write the sequence '\''
to get the single quote:
echo '"single quotes" ('\'') are harder than "backslashes" (\)'
where I included double quotes and backslashes to make it harder to use double quotes around the string. However, you could also write:
echo "\"single quotes\" (') are harder than \"backslashes\" (\\)"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments