The assignment and operation in the shell is the string processing by default, here are some special methods of mathematical operation in the shell, which can be seen later, hehe1. Examples of error methodsAVar=1+1Echo $varThe result of the output
The Shell's own abilities.Writing scripts is OK, at least now I'm running a script on the InternetProgram-Log scheduled backup and delete, NFS Shanghai volume file Delete and send mail."Data"Export
1. Create a hierarchy directory: Use the-P option for mkdir, such as Mkdir-p tmp/a/b/c.2. Unpack to the specified directory: Use the-c option of tar, such as tar xvf newarc.tar.gz-c tmp/a/b/c.3. Joint command: Use;, &&, | | such as control operators,
Linux Basics (vi)Three loops and function knowledge points in shell scriptsFirst, the process control if structure1. Simple If instance:#!/bin/bashVar='/ETC/INIT.D'#var= '/DEV/SDA 'if[ -d $var] then echo"$var is directory"elif[ -b $var] then
If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.As an example:
#!/bin/bash
A=ten
echo-
A string interception of Linux is useful. There are eight ways.Suppose there is a variable var=http://www.linuxidc.com/123.htm 1 # Intercept, delete the left character, and leave the right character. Echo ${var#*//}where Var is the variable name
First script file
Copy Code code as follows:
#!/bin/bash
echo "This are my I-A-bash code!"
Exit 0
redirect Symbols and mathematical calculations
Copy Code code as follows:
#!/bin/bash
Echo-n "The time and
First, describe
The Intval function has an attribute: "Until a number or symbol is encountered to do the conversion, and then to the end of a non-numeric or string end conversion", in some applications due to the characteristics of the Intval
2. Correct method1) Use LetVar=1Let "Var+=1"Echo $varThe output is 2, no tragedy this time.Attention:A) I tested let almost support all operators, see an article on the internet said "let does not support + + 、--and comma, (,)", but after I test the
1, the permissions of the directory: R indicates that the directory can be displayed. W indicates whether the file under the directory can be created, deleted, renamed and other operations. x indicates whether the directory can be entered and the
What is a shell, what can you do?1. ProceduresNarrow: Operating system programs and applications.The operating system program is used to invoke the monitoring kernel, which runs all the programs we can apply on this operating system.The operation of
Reference documents:Summary of Shell interception string methods in LinuxHow does [Linux] calculate string lengths in shell scripts?There are eight ways to intercept a string, mainly for the following methodsThere are a number of ways to intercept
#!/bin/sh mypath= "/var/log/httpd/" myfile= "/var/log/httpd/access.log" #这里的-x parameter Judging $ Whether the MyPath exists and has enforceable permissions if [!-X ' $myPath]; then mkdir "$myPath" fi #这里的-D parameter to determine if
There are a number of ways to intercept strings in the shell, ${expression} There are 9 ways to use them. ${parameter:-word}${parameter:=word}${parameter:?word}${parameter:+word} The above 4 alternatives can be used for default values. ${#parameter}
1.3 Playing variables and environment variablesvariables are an essential part of any programming language and are used to store variables of various types. Scripting languages are mostly weak type languages (dynamic languages), meaning that when
Reference: http://blog.csdn.net/wanglang3081/article/details/49423105 (1) Makefile is essentially a shell script, that is, each command is a shell process, and the shell process exits when it finishes running. (2) Shell code line, if there is =,
I. Script structureThe script for the shell under Linux is to write a series of command sequences in a text file, and this text file can be executed. Development efficiency increases relative to the command line. So his architecture has 2 parts that
1. In bash, the value of each variable is string 2, view the environment variable of a process cat/proc/$PID/environ | TR ' \ s ' \ n ' 3, variable assignment 3.1, var=value, note that var = value is not an assignment operation, but an equality
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.