4 commonly used escape characters
- Backslash (\): Make a variable after the backslash a simple string.
[root@xsnq ~]# echo "\"xsnq\""
"xsnq"
- Single quotation mark (''): escape all variables in it as simple strings.
[root@xsnq ~]# a=xsnq
[root@xsnq ~]# echo $a
xsnq
[root@xsnq ~]# echo '$a'
$a
- Double quotation marks (""): Keep the variable attributes in it, without escaping.
[root@xsnq ~]# a=xsnq
[root@xsnq ~]# echo "$a"
xsnq
- Backquote (``): Return the result after executing the command.
The key under Esc
[root@xsnq ~]# pwd
/root
[root@xsnq ~]# echo `pwd`
/root
If there is any error in this article, please leave a private message to criticize and correct.
Previous section (shell tutorial-the first shell script)
next section (shell tutorial-shell variables)