Importance of Quoting in Strings

suggest change

Quoting is important for string expansion in bash. With these, you can control how the bash parses and expands your strings.

There are two types of quoting:

If you want to bash to expand your argument, you can use Weak Quoting:

#!/usr/bin/env bash
world="World"
echo "Hello $world"
#> Hello World

If you don’t want to bash to expand your argument, you can use Strong Quoting:

#!/usr/bin/env bash
world="World"
echo 'Hello $world'
#> Hello $world

You can also use escape to prevent expansion:

#!/usr/bin/env bash
world="World"
echo "Hello \$world"
#> Hello $world

For more detailed information other than beginner details, you can continue to read it here.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents