The quotation mark application in LinuxShell programming-general Linux technology-Linux programming and kernel information. The following is a detailed description. In Shell programming, three quotation marks are used: Double quotation marks (double quotation marks), single quotation marks (single quotation marks), and anti-quotation marks (the one with a wavy line and one key), which are very convenient to use in different applications.
1. Double quotation marks
Double quotation marks can be used to reference any character or string except the characters $, ', and. These special characters are dollar signs, backquotes, and backslashes, which have special significance for s h e l. If you use double quotation marks to assign a string to a variable and feed it back, it is actually no different from the direct feedback variable. Double quotation marks are often used to query strings containing spaces.
A. Print characters directly using double quotation marks:
Echo "My Day"
My Day
B. replace variables in double quotes
$ STR = "My Day"
Echo "$ STR"
My Day
2. Single quotes
The single quotation marks are similar to double quotation marks. The difference is that s h e l ignores any referenced values. In other words, if special meanings are shielded, all characters in quotation marks, including quotation marks, are considered as a string.
STATUS = "well"
Echo "I feel '$ status '"
I fell 'well'
3. Reverse quotation marks
Backticks are used to set the output of system commands to variables. S h e l uses the content in the quotation marks as a system command and executes the content. This method can replace the output with a variable. Backticks can be used with backticks.
Echo 'date'
Sun Jan 13 15:23:34 GMT 2007
In terms of text processing, Shell programs have powerful capabilities in combination with sed and awk.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.