Shell common list of special variables

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

Special usage of $0,$?,$! in shell

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.

Shell Programming Case Statements

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

A classic and practical iptables shell script

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

shell-Special variables

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.

Shell script Execution Conflict event-ssh&while

Today we find a problem: Read the following script: [email protected]/0 # cat ! $cat  /tmp/test_nginxls *.txt |  tr  '   '   ' \ n '  | while read linedo echo  $lineif  [  ' Yes '  ==  ' yes '  ]thenssh  192.168.109.10  ' echo  ' yes ' "elsessh  192.

Split usage in Linux shell

[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

Shell Regular Expression

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

Shell Syntax format

Shell Syntax formatIf statementIf conditionThenCommand sequenceFiIf conditionThenCommand sequenceElseCommand sequenceFiIf conditionThenCommand sequenceElif conditionsThenCommand sequenceElif conditionsThenCommand sequenceElseCommand

Shell script extracts a specified number of random students

#!/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 '

Shell, not successful

###### #时钟#!/bin/bashMin=1Hour=1for ((sec=5; sec>=0; sec--))DoEcho-ne "${hour}:${min}:${sec}s End"Sleep 1Echo-ne "\ r \ r"While ["$SEC"-le "0"-a "$MIN"-ge "0"]DoEcho-ne "${hour}:${min}:${sec}s End"Echo-ne "\ r \ r"((min--))Sec=60While ["$MIN"-lt "0"-

Tips for using tput in shell scripts (Tput control cursor position)

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:

Shell scripting Exercises (12.11)

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

Shell script Remote Batch execution command

#! /usr/bin/expectset ip 10.91.96.                  ######    Network Segment Set time 30set username  root#### #for  {set ip 11} {$ip > /etc/login.defs\r "send " echo PASS_MIN_DAYS  5 >> /etc/login.defs\r "send " echo pass_warn_age 7 >> /etc/ Login.

Initial shell, set port parameters

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 '

Initial shell, set SELinux parameters

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-

Shell scripting Exercises (12.7)

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;

Seven. Shell script programming

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

Bash Shell array variables

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

Enterprise Shell interview questions: Get 51CTO Blog list Reverse sort exam questions

#!/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binHTMLFILE=/home/oldboy/htmlHTTP=http://oldboy.blog.51cto.com/all/2561410NUM=$(curl $HTTP |awk-F "[ /]"‘/页数/ {print $(NF-3)}‘)[ -d $HTMLFILE ]||mkdir$HTMLFILE -pecho

Total Pages: 541 1 .... 417 418 419 420 421 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.