Shell tutorial-4 commonly used escape characters

4 commonly used escape characters

  1. Backslash (\): Make a variable after the backslash a simple string.
[root@xsnq ~]# echo "\"xsnq\""
"xsnq"
  1. 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
  1. Double quotation marks (""): Keep the variable attributes in it, without escaping.
[root@xsnq ~]# a=xsnq
[root@xsnq ~]# echo "$a"
xsnq
  1. 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)

Guess you like

Origin blog.csdn.net/weixin_46623617/article/details/112840550