How do we separate variables from letters in shell scripting?

前端 未结 5 580
误落风尘
误落风尘 2020-12-11 14:37

I tried printing \"Dogs are the best.\" with this bash script.

#!/bin/bash

ANIMAL=\"Dog\"
echo \"$ANIMALs are the best.\"
exit 

However, I

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-11 15:39

    Just surround the variable's name with curly braces.

    #!/bin/bash
    
    ANIMAL="Dog"
    echo "${ANIMAL}s are the best."
    exit 
    

提交回复
热议问题