Explain the single and double quotes

This commit is contained in:
Randy8080 committed 2021-12-30 10:01:25 +08:00
1 parent 8f9890a1ba
commit 0ee7536fe8
1 file changed
+9 -7
+9 -7
View File
@@ -36,13 +36,13 @@ $ bash hello.sh
```bash
NAME="John"
echo ${NAME} # => John
echo $NAME # => John
echo "$NAME" # => John
echo '$NAME' # => $NAME
echo "${NAME}!" # => John!
echo ${NAME} # => John (Variables)
echo $NAME # => John (Variables)
echo "$NAME" # => John (Variables)
echo '$NAME' # => $NAME (Exact string)
echo "${NAME}!" # => John! (Variables)
NAME = "John" # => Error (about space)
NAME = "John" # => Error (about space)
```
@@ -126,8 +126,10 @@ See: [Brace expansion](http://wiki.bash-hackers.org/syntax/expansion/brace)
### Shell execution
```bash
# => I'm in /path/of/current
echo "I'm in $(PWD)"
# Same
# Same as:
echo "I'm in `pwd`"
```