Home > Net >  Bash echo special character
Bash echo special character

Time:07-15

I want to print out below string literally with echo

"${placeholder.test}" '(

I have looked at all similar issues and here are what I have tried

echo ""${placeholder.test}" '(" gives bad substitution error

echo '"${placeholder.test}" '(' gives unexpected token `('

echo '"${placeholder.test}" '\(' command not exit unless I enter another '

I also tried printf but same issues

any solution?

CodePudding user response:

I suggest using here-doc to avoid any escaping:

cat <<-'EOF'
"${placeholder.test}" '(
EOF

However if you really want to use echo then use:

echo '"${placeholder.test}" '"'("

"${placeholder.test}" '(
  •  Tags:  
  • bash
  • Related