#!/bin/baship=$ (ifconfig eth0 |grep "inet addr" | awk ' {print $} ' |cut-f1-d ":") a=$ (df-h |grep/dev/sda2 |awk ' {print $} ' |cut-f1 -B "%") #截取分区使用率If [$a-ge] then echo "$IP the server root partition is about to have no space, please clean it up
1. Use the & symbol to execute commands in the backgroundYou can add the & symbol to the Linux command or script to make the command or script execute in the background, for example:.$./my-shell-script.sh &2. Use Nohup to execute commands in the
In order to do cluster testing, 3 tomcat is installed on each machine, each time the project is released, it is necessary to repeatedly knock some commands, check that the Tomcat process has not stopped before restarting Tomcat, and kill the process
First, if else1.1, ifIf statement syntax format:if condition Then command1 command2 ... fiWrite a line (for the terminal command prompt):if [$ (PSgrep"ssh"1thenecho" True"fiAt the end of the fi is if the upside-down spelling, and later
Case-then the previous caseWant to bulk delete all users created in the previous caseScript Show: (Next time explain)#!/bin/bashecho > userlist.txt;for i in `seq 50`do id student$i >/dev/null 2>/dev/null; [ $? -ne 0 ] && echo -e "[\033[31merror\033
1.export commandThe Linux Export command is used to set or display environment variables.When executing a program in the shell, the shell provides a set of environment variables. Export can add, modify, or delete environment variables for use by
1, write the script/root/bin/createuser.sh, to achieve the following functions: Use a user name as a parameter, if the specified parameter of the user exists, it will show its existence, otherwise added; Displays the ID number of the added user and
Use of function functions for shell scripts? The basic things in front of the introduction, the following we introduce the function how to use.? Note: The function needs to be declared before it can be used.? The declared keyword can be used with
1. Date view modify system time and dateDate-DDisplays the time of the string description-FShow each line of time in the Datefile file-RDisplays the last modified time of the file-RDisplay time in RFC-2822 compatible date format-rfc-2822Display time
Sed tool "streaming editor"--Non-interactive, filter based on pattern matching and modify text--progressive processing and output of the results to the screen--can achieve the output of the text, delete, replace, copy, cut, import, export and other
file Expression-e filename true if filename exists-d filename If filename is a directory, true-F filename True if filename is a regular file-L filename True if filename is a symbolic link-r filename If filename is readable, true-W filename if
1/ETC/PASSWD: User account information/etc/shadow: Secure user account information/etc/group: Group account information/etc/gshadow: Security group account information2ID: View the user ID and group ID of the current userId-u: Show only User IDId-u
Looping statementsThe looping statements in the shell are as follows:
for
while
unitl
case
select
For/while/unitl must end with done
forCycleforLoops are used to iterate through an array (data list) or
2. process file 2.1 Create file TouchIf you want to change the access time only, you can use the-a parameter.$ ls-l Test_one-rw-rw-r--1 Christine Christine 0 may 14:35 Test_one$ touch-a Test_one$ ls-l Test_one-rw-rw-r--1 Christine Christine 0 may 14:
Pipe character and job control
| Give the result of the previous command to the following command processing.[[email protected] ~]# cat 1.txt |wc -l 统计行数5[[email protected] ~]# cat 1.txt |grep ‘aaa‘aaaa 剪切出aaa的行
CTRL Z pauses a task,
Case Base Syntax:Format case?? Variable name invalue1)Command;;value2)Command;;*)Commond;;EsacIn a case program, you can use the |, meaning, or means of a condition, such as???2|3)Command;;Script[[email protected] shell]# vim case.sh #!/bin/bashread
Format 1:if condition; Then statement; FiFormat 2:if condition; Then statement; else statement; FiFormat 3:if ...; Then ...; Elif ...; Then ...; else ...; FiLogical judgment expression: if [$a-gt $b]; If [$a-lt 5]; If [$b-eq 10] et-gt (>); -lt (=); -
Array: A variable that stores a set of data and is able to manipulate one of the data in this set of data individually.Types of arrays: one-dimensional arrays, two-dimensional arrays, multidimensional arraysTypes of variablesThe default value of an
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