In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article gives you a detailed introduction to the relevant content of quotation marks in Linux, which is shared for your reference and study. Let's take a look at the detailed introduction:
Quotation mark
We're going to put the scripting aside for a while and then talk about some of the things we've been using but haven't explained. Quotation marks in this section, we will talk about quotation marks. Quotation marks serve two purposes:
Control character substitution and perform the function of including words together
We have used quotation marks. In our script, the assignment of text information to a constant uses quotation marks:
In the above example, the text message is enclosed in double quotes. The reason we use double quotation marks is that we have to treat all words as a whole, including living. If we don't use quotation marks, then the bash interpreter interprets all words after the first word as other commands (the first word is interpreted as a command).
Try running the following command to see how it works:
Single and double quotation marks
The shell interpreter can recognize double and single quotation marks. The following copy expression effect is equivalent:
However, there is an important difference between double quotes and single quotes. Single quotation marks with restrictions on character substitution. As we saw in the previous section, you can enclose a variable in double quotes, while the shell interpreter still performs character substitution on the variable.
We can see this effect by using the echo command:
If we change the above double quotation marks to single quotation marks, the behavior will change:
Double quotation marks do not limit the character substitution of variables that begin with "$", but it does limit the extension effect of wildcards.
For example, here is an example:
Reference a single character
There is another kind of reference character that you will encounter. It's the backslash. The The backslash tells backslash tells the shell interpreter to ignore the first character after the backslash character. For example:
By using the backslash, the shell interpreter ignores the interpretation of the "$" symbol. Now that shell has ignored "$", the shell interpreter will not perform character substitution on $HOSTNAME.
Here is a more useful example:
As you can see, by using the backslash symbol, we can include double quotes in the text.
Other techniques for using backslashes
If you have read the user manual of any software and this manual is completed by the GNU project, you will find that in the command options of the software, in addition to the form of an underscore _ plus a letter, there are also two underscores plus a complete word. For example, the following two statements are equivalent:
Why are both forms supported in software? The short form is specially designed for lazy typists, while the long form is designed for scripting. I sometimes mix the above two forms, and then I find it useful to use long command options, if I write a script, and I will read it in a few months. Seeing the long command option helps me understand what this command option means, thus saving me the effort of looking up the man manual. A few more keystrokes now will save a lot of effort in the future. In this way, the principle of laziness is maintained.
You may suspect that using a long command form will cause a single command to become very long. To combat this problem, you can use a backslash to make the shell interpreter ignore newline symbols, as follows:
Using a backslash like this allows us to include the contents of each line in a separate command. For this technique to be applied, note that line breaks must appear immediately after the backslash (that is, after the backslash is entered). If you place a space character after the backslash, the space symbol will be ignored, not the newline character. The backslash character can also be used to insert a special symbol into the text. Special characters into our text. These symbols are called transfer characters, and here are some transfer characters:
Escape character.
First name
Possible uses
N
Newline character
Add a blank line to the text
T
Tab character
Add a horizontal tab to the text
A
A reminder
Let your terminal beep.
\
Backslash
Insert a backslash character
F
Formfeed
Sending this to your printer ejects thepage
The application of transferring characters is very common. It is very common to transfer characters, and the idea first appeared in the C language. Programming languages Today, the concept of transfer characters is used by the shell interpreter, the Clipper PerlPythonPerlPythonPerlPythonJet, and other programming languages. We will show the application of the above transferred characters by using the-e option of the echo command:
Summary
The above is the whole content of this article, I hope that the content of this article can bring some help to your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
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.