Linux escape character

(1) escape character "\"

If the "\" put special characters in front, shell ignores the original meaning of these special characters,
to treat them as ordinary characters, such as:

[root @ WEBServer ~] #ls
? abc * C: \ Backup
[root @ WEBServer ~] #mv abc \ \ * abc?
[root @ WEBServer ~] #mv C \: \\ Backup Backup
surface, on is abc? * rename abc, the C: \ backup rename the backup. Because the file
name contains special characters, so it is Using the escape character "\."

(2) single quotation mark " '"

If the string into a ⼀ between single quotes, the string containing all the special characters of
righteousness will be ignored, for example:

[root@WEBServer ~]#mv C\:\\backup backup
[root@WEBServer ~]#mv 'C:\backup' backup

The above two commands are exactly equivalent

(3) double quotation marks "" ""

Quote double quotes with single quotes basically the same, enclosed in double quotation marks most of the special characters
can be used as an ordinary character, but there are even some special characters Use double quotation marks, it
still retains its own special meaning, such as " $ "," \ "and" `."

[root @ WEBServer ~] # str = "at The \ $ SHELL Current shell IS $ SHELL"
[root @ WEBServer ~] # str1 = "\ $$ SHELL"
[root @ WEBServer ~] $ str #echo
at The $ SHELL Current shell iS / bin / the bash
[WEBServer the root @ ~] #echo str1 $
$ / bin / the bash
can be seen from the above output, "$" and "\" in double quotes remains a special meaning.

[root@WEBServer ~]# str="This hostname is `hostname`"
[root@WEBServer ~]# echo $str
This hostname is WEBServer

The output above, the character "` "in double quotes also retains its own special meaning.

Guess you like

Origin www.cnblogs.com/myworld5218/p/11278230.html