variables and quotes in bash scripts

I created the following function the other day because I also forget how the quotes and variables works in my bash scripts:


function printQuotes() {

        A="ASTRING"
        echo echo without quotes $A
        echo echo without quotes ${A} curly braces
        echo "echo quotes $A"
        echo 'echo single quotes $A'
        echo "echo quotes ${A} curly braces"
        echo 'echo single quotes ${A} curly braces'

}

Which results in:

echo without quotes ASTRING
echo without quotes ASTRING curly braces
echo quotes ASTRING
echo single quotes $A
echo quotes ASTRING curly braces
echo single quotes ${A} curly braces
This entry was posted in software, tips and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *