Variable
Meaning
$
Gets the file name of the current execution shell script
$n
Arguments passed to the script or function. N is a number that represents the first few parameters. For example, the first
Variable Description:$$ The PID of the shell itself (Pro CESSID) $! PID of the last background process run by the shell $? End code of the last command run (return value) $- Flag list set with the SET command $* All parameter lists.
Bash Script Programming:Case statement:Multi-Branch If statement:if CONDITION1; ThenBranch 1Elif CONDITION2; ThenBranch 2...else CONDITION; ThenBranch NFiExample 1: Display a menu to the user;CPU) Display CPU informationMEM) Display Memory
PS: This iptables script is good, very practical, according to the actual application changes can be used by themselves. Share it for everyone to reference. Original author Anonymous. The source code is as follows:#!/bin/sh#Modprobe
Position variable.$ $ Gets the file name of the currently executing shell script.[Email protected] ~]# vim 0.sh[email protected] ~]# cat 0.shEcho[[Email protected] ~]# sh 0.sh0.sh[Email protected] ~]#
If I put it in the full path, it will.
[email protected] ~]# split [-BL] File PREFIXParameters:-B : Can be divided into the file size, can be added units, such as B, K, m, etc.;- L : Split by number of rows.Example:Example One: my/etc/termcap has more than 700 k, if want to divide into 30
Regular expressions
Used primarily for pattern split/match/Find and replace operations on strings.
Regular expressions and wildcard characters
Wildcard charactersThe difference between a regular and a wildcard:
A regular match string
#!/bin/bash##!/bin/bash#read-p ' input number ' C #指定抽取的学生人 Number of jw= (' Wang Hao ' Shei Yunsheng ' ke Yang ' He Shingyu ' Repeti soldier ' Dengbellin ' ' Liu Dao ' ' Yang Jidong ' Chu Ziwen ' ' ' Salted fish ' ' Yang Dong ' > Huang Tinghui '
Knowledge Points:1) Sleep: Used to implement the delay function in the script, sleep N, delay n seconds2) Tput: Change the terminal display characteristics, common usage is as follows:Tput lines: Displays the number of lines of the terminalTput cols:
For an even number of 100 or lessIdea: 1. Define a variable x firstThe range of 2.x is 0-50,x with an initial value of 13. And the value initial value is 0, each time the loop and the value is equal to itself +2*iMethod One:Vim
In fact, I deliberately do not write the deletion of the section, because the management of the server will only add port will not shut down.=====================#! Bin/bashWhile:DoClearecho "Detect Open Ports:"Echo-e "\033[33m '
Turning off SELinux should be replaced with user input variables, but that's fine.==========================================#! Bin/bashClearecho "--------------------"Echo-e "\033[34mthis file controls the state of SELinux on the system.\033[0m"Echo-
Example 1. Enter any two numbers and make a judgmentVI number.sh#!/bin/bash#written by Lizhengecho "Please enter the number"Read aRead Bif test $a-eq $bThen echo "The No.2"Elif Test $a-gt $bThen echo "The > no.2"else echo "The Fi650) this.width=650;
Shell login mode, shell arithmetic operation, Shell logic operation, shell condition test, Shell selection statementShell programming in the first line indicates the path of the shell type to be executede.g #/bin/bash1. Shell Login MethodInteractive
First, define the array variable1. Grammar(1) arrayname= (parameter1 parameter2 ...)Example 1, define an array named name, with a value of Claire,obama,georgeName= (Claire Obama )(2) Arrayname= (Parameter1Parameter2...)Again we change example 1 to
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