shell quotes

1. backslash

  a. be able to immediately followed by a single character as character literal

  Multi-line input b. In the last used \ carriage return command, submitted to shield functions to achieve the commanded

    Example: 

[root@VM_0_3_centos ~]# echo \*
*
[root@VM_0_3_centos ~]# echo \>
>
[root@VM_0_3_centos ~]# find /\
> -name "test.txt"\
> -type f \
> -size +5M
find: ‘/-name’: No such file or directory
find: ‘test.txt-type’: No such file or directory
find: ‘f’: No such file or directory

2. single quotes

  a. single quote character in the middle of all the reduction of any literal meaning, the shielding shell meta characters, single quote must exist in pairs.

[root@VM_0_3_centos ~]# echo $HOME
/root
[root@VM_0_3_centos ~]# echo '$HOME'
$HOME

3. double quotes

  a. similar to single quotes, but it does not block, \ $ three characters. If you need to shield the meaning of these characters need to be added in front of \

Case

[root@VM_0_3_centos ~]# age=18
[root@VM_0_3_centos ~]# echo "the age of xiaoming is $age years old"
the age of xiaoming is 18 years old
[root@VM_0_3_centos ~]# echo "the age of xiaoming is \$age years old"
the age of xiaoming is $age years old

4. Anti-quotes

  a. Use the $ () is similar, it is used to reorganization of the command line, first complete quotes the command line, and then replace the result out, and then re-form a new command-line, but there are also different.

    1. Backticks Qi itself to \ been escaped, retaining the Qi itself mean, if we want to play in the anti-quotation marks \ special meaning, we have to use 2 \ to represent.

      So we can simply think of anti-quotes:  \\ = \

    2. $ () Need not be considered in \ problem, like we normally use: \ = \

[root@VM_0_3_centos ~]# echo `echo \\\\\\\w`
\\w
[root@VM_0_3_centos ~]# echo $(echo \\\\\\\w)
\\\w

 

Guess you like

Origin www.cnblogs.com/icase/p/11118935.html