April 2018
Beginner
284 pages
7h 3m
English
So far, we have used a simple double-quoting mechanism to encase the strings that we want to use with echo.
In the first script, it does not matter if we use single or double quotes. echo "Hello World" will be exactly the same as echo 'Hello World'.
However, this is not the case in the second script, so it is very important to understand the quoting mechanisms available in bash.
As we have seen, using double quotes in echo "Hello $1" will result in Hello fred or whatever the supplied value is. Whereas, if we use single quotes in echo 'Hello $1', the printed output on the screen will be Hello $1; that is, we see the variable name and not its value.
The idea of the quotes is to protect special characters, such ...