Op-ExpressionsThe expression is contained in or (()) or [] within,
An arithmetic expression:(())
((expression))
This expression is calculated according to the rules of arithmetic calculation. Equivalent to let expression .
8.10 Shell Special Symbol Cut command
: Represents any arbitrary character? : Represents any single character#: Denotes comment characters\ denotes a de-semantic character| Represents a pipe characterThe Cut command is used to intercept a
In the shell script, the variable definition, the reference each has the different way, in addition, very commonly has the file attribute judgment, the logical operation, the numerical operation and so on, the following record their attribute
There are two ways to send a shell script:Way 1:sh file.sh arg1 Arg 2 ....Mode 2:read-p "hint" Arg 1 arg2The default parameters are directly separated by a space, following a few examples to explain the problems encountered in the communication and
Preface: Before we get to the point, let's review the conditional tests on scriptingOne, Process Control
Over-programming languagesA. Sequential executionB. Select executionC. Cyclic execution
Sequential executionAs the name implies, it is
1. String length:Var=123abc456echo ${#var}9expr length $var 92. Specify character interceptionEcho ${var:5} #截取前五个字符c456echo ${var:2:5} #截取第2到第5个字符3abc4echo ${var: 3} 3 characters after intercept (with space on the left) 4563. Interception of
The wildcard asterisk number (*) represents a question mark (?) that matches 0 or more characters. Represents a matching single character in parentheses number ([0-9]) that represents a single digit character between matching 0~9 brackets plus the
Receiving user parameters#./example.sh One and threeThe Shell scripting language includes variables for receiving user parameters, and based on the above command, the commonly used variables are as follows:
Use $ A To get the file name of
Exercise 1:Delete the letters in the textRequirements: Delete the line containing the letters in the first 5 lines of a text document and delete all the letters from 6 to 10 lines (file 1.txt, lines greater than 10 lines)Reference Answer:#!/bin/bash#
The article is for personal opinion, please correct me.
Before we introduce the shell script, let's begin by understanding some basic concepts. What is a program? Process? The program is a set of instructions plus data, the following diagram
There are three standard input and output in Linux, namely Stdin,stdout,stderr, the corresponding number is 0,1,2.STDIN is a standard input that reads information from the keyboard by default;STDOUT is the standard output, by default output output
First, regular expressionBefore learning the Find command, we have been exposed to some simple regular, so we can now learn some complex regularization. First of all, we still have to review what is regular expression, see this tutorial first, must
We can pass parameters to the script when executing the Shell script, and the format of the parameters obtained in the script is:$n. n represents a number, 1 is the first argument to execute the script, 2 is the second argument to execute the script,
1.shell condition judgmentCommand: Test or [Use "[" to End With "]" and a space between judgment statementssuch as: Determine if the demo.c file existsIf [-F DEMO.C]Then...FiOrIf Test–f demo.cThen...Fi1.1 String Comparisonsstring1 = string2 Same as
1.shell command interpreter or shell auto-ops language2. How to execute a shell script(1) Execute permission must be given./first.sh(2) SH first.sh(3) Source first3. More complete Script compositionScript DeclarationComment InformationExecutable
Shell script is similar to batch processing under Windows/dos, that is, the use of various commands pre-placed into a file, convenient one-time execution of a program file, mainly for the convenience of administrator settings or management. However,
Shell variable type: (Divided into two categories)Environment variables (global variables) and local variables###### #一般环境变量都为大写 #########Three symbols of the variableNo quotation marks: usually consecutive strings, numbers, paths, etc. can be
Arrays are not used very often in the shell, but are very useful, let's take a look at some of the uses of arrays in the shell:
Define array a= (1 2 3 4 5); Print array echo ${a[@]}The contents of the array can be either numbers or letters, as
Shell: Shell Process Control details, shell Process Control detailsShell: Shell Process Control details if else
If statement
Syntax:
if conditionthen command ...fi
Eg:
#!/bin/basha=100b=100if [ $a == $b ]then echo "$a == $b"fi
Output:
100 ==
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service