In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about the difference between single quotation marks and double quotes in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Difference: single quotation marks are strong quotes, it ignores the special treatment of all quoted characters, and quoted characters are used intact, while double quotes are weak quotes, which give special treatment to some characters that are caused. To put it simply, single quotes directly output internal strings without parsing special characters, while special characters are parsed within double quotes.
The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.
1. Single quotation marks
Single quotation marks are strong references, which ignore the special handling of all quoted characters, and the quoted characters will be used intact. The only point to note is that self-reference is not allowed.
Single quotation marks treat all its contents as strings, ignoring all commands and special characters, similar to the use of a string
Echo 'This is a string' > This is a stringecho' ls. / > > ls. /
2. Double quotation marks
Double quotation marks are weak references, which give special treatment to some characters that are caused.
Double quotation marks differ from single quotation marks in that they can contain special characters (single quotes directly output internal strings without parsing special characters; within double quotes special characters are parsed), including', ", $,\. If you want to ignore special characters, you can use\ to escape, ignore special characters, and output as ordinary characters:
Var = 1echo'$var' > > $varecho "$var" > 1echo "Here 'this is a string' is a string" > Here' this is a string' is a stringecho "Here\" this is a string\ "is a string" > Here "this is a string" is a string
3. Backquotation marks
Backquotes are used to contain a command string in which the command is executed first, and the resulting result is returned to the layer command before execution:
Echo `echo 'this is the inner string' `+' out' > this is the inner string+outecho `echo 'this is the inner\ `string'` +' out' # escape back quotes > this is the inner `string+out
Backquotes are similar to $(command).
# A usage example, if you want to traverse the current folder and its first-level subfolders: ls $(ls) ls `ls` > > first_folder > sub_1.. sub_2 > second_folder > sub_1.. sub_2 > Thank you for reading! This article on "what is the difference between single quotation marks and double quotation marks in linux" is shared here. I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.