Shell script simulates Nginx service startup and shutdownNote: 3 slashes////is followed by a representation of the interpretation of the current statement, which must be removed in the actual script#!/bin/bash///defines which scripting language
One, for-done (not very common)1. GrammarFor variable in name table do ... done2. Script Sample Code#!/bin/shfor num in 1 2 3 4 5do echo "number is $num" done3. Execute script[Email protected]]# sh hello.sh4. Implementation resultsThe number
First, ifSyntax format: If test-d $arg then ... else ... fiVariable test statements can be simplified with []. Example: test-d $arg equivalent to [-D $arg]. (Note: "Space" ["Space"-D "space"])For more test commands see: http://www.cnblogs.com/fangwu/
common syntax for conditional testing:
Syntax format
Description
[]
[] has at least one space between the boundary and the content
[[ ]]
[[] There is at least one space between the
Using shell functions to develop the Rsync service startup script, previously unprofessional#!/bin/bash#chkconfig: 2345 20 80 #这两行加入kconfig #description: saves and restores system entropy poolsource /etc/init.d/functions
1.!#/bin/bashThis is the first line of the shell script, and/bin/bash represents the location of the script's interpreter.2. Run the script: (1) Bash test.sh(2) Bash-x test.sh (ps:-x for observing script running state)(3) Release script
Shell script exercises 1. Script/root/bin/systeminfo.sh, which displays the current host system information, including hostname, IPV4 address, operating system version, kernel version, CPU model, memory size, hard disk size. #!/bin/bash
1. Execution style of the programProgram Programming Style:Past: Command-centric, data-serving instruction.Object type: Data-centric, instruction serves data.Program programming has the following characteristics:1) Sequential execution: refers to
1. Shell: Command interpreter1) supported shells are saved in/etc/shells2) Default shell is/bin/bash2. Shell script writing:1) using the VI Editor2) One command per line, followed by3) Give executable permissions (x)3, the way of implementation:1)
8.1 Shell IntroductionThe Linux shell is simply a process of a command line and user interaction. You make an order and it will result. Similar to the CMD window inside windows.8.2 Shell Command HistoryAll the commands that have been knocked out
Demand:Write a script that calculates the amount of memory that is consumed by all processes in the Linux system. (hint, use PS or TOP command)#!/bin/bashtime= ' date +%y-%m-%d-%h:%m:%s ' # #方法一s =0for m in ' ps aux |awk ' { print $6} ' |grep -v
Method 1: Use the wc-l commandWc-l can get the length of the current row, so the string for a single row can be obtained in this simple way, and the wc-l is the number of rows that get the current string content.The code is as follows: Echo "ABC"
By defaultShellis not timed out automatically, but it is sometimes necessary for it to automatically exit the terminal after a period of inactivity without an operation. 1. Create a file /etc/profile.d/autologout.sh :#
Mathematical calculations in the shellOne, use square brackets#!/bin/Basha=tenb=c=res=$[$a * ($c-$b)] Echo $resIi. usage of BCBC Technology is actually a programming language that recognizes: numbers (integers and floating-point numbers)
Special symbols
Wildcard characters, any character? Any of the characters. #注释字符\ de-Semantic characters| Pipeline
Several commands related to pipelinesCut select information for the row analysisMain parameters-B: Split in bytes. These
8.1 Shell IntroductionThe shell is a command interpreter that provides interaction between the user and the machine to support specific syntax, such as logical judgment, looping each user can have their own specific shell CentOS7 default shell for
Format: echo "/033[word background color; font color m string/033[control code"If you simply display the font color can be fixed control code bit 0m.Format: echo "/033[word background color; font Color m string/033[0m"Word background color range: 40-
Real-time monitoring of the local memory and the remaining space on the hard disk, the remaining memory is less than 500M, the root partition remaining space is less than 1000M send alarm message to the root administrator1 Writing scripts[Email
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.