In Python, there are many modules that enable concurrent programming, such as threading, processing, Eventlet, and Stackless python.
So how does it work for the shell? In fact, the principle is very simple, I used the method is:1. The tasks that
Take. SVN example
For example, if I want to delete all the. SVN directories under/data/web/, then execute the following command.
The code is as follows
Copy Code
Cd/data/webFind. -type d-name ". SVN" |xargs RM-RVF
To get the server IP shell script:
The code is as follows
Copy Code
#!/bin/bashIfconfig | grep ' inet addr: ' | Grep-v ' 127.0.0.1 ' |cut-d:-f2 | awk ' {print '} '
Download Whole Station
WGET-MK
1 if statementThe format of the IF statement:If condition then command fiIf condition then command else command fiIf condition then command elif condition then command else command fiExample:Determines whether the current user is root, and if so,
* Multiple? 1 x# annotation Characters\ de-Righteous characters| Pipe character$ as a prefix for variables, used for variables!$ using the last parameter of the previous command; Used in the middle of two commands to write in one line~ User's Home
To the basic structure of the For loop:The condition of the for variable name in the loop;CommandDoneExample 1[email protected] ~]# cat for1.sh#/bin/bashFor i in ' SEQ 1 5 ';d oEcho $iDoneThe "condition of the loop" here can be written as a set of
Functions: functionProgram Programming: Code ReuseModular programmingStructured programmingThe code of an independent function as a whole, and a name for it; a named code snippet, which is a function;Note: The code snippet that defines the function
Globbing: File name wildcard (whole file name match, not part)Match pattern: metacharacters*: matches any character of any lengthpa*, *pa*, *pa, *p*a*PA, PAA, passwd?: matches any single characterPa??? PA, P?a, P?a?PA, PAA, passwd[]: matches any
Organized a number of shell-related exercises, recorded here.1. Please follow the date format xxxx-xx-xx to generate a daily file, for example: The file generated today is 2013-09-23.log, and the use of the disk is written to this file.1 #!/bin/bash2
CMD is also a shell of Shell windowns.View files and folders dirmkdir * * * Create folder Rd* * Delete folder (should have parameters, recursion, etc.)Ctr+c Abort Commandcd>***.** Creating a file del filename Type + relative path view
#!/bin/bashread-p "Please enter the number of start:" Minread-p "Please enter the number of terminations:" Maxif [$min-gt $max]thenecho "Start number is greater than the number of terminations! "Elseecho-n" random number: " ; expr $ (date +%n)% $[
The day after tomorrow to reply, today only brush a question, have not written out, but want to update the blog, so only to write the previous things posted out.A shell script for partitioning1 #!/bin/Bash #指定脚本解释器路径 2 echo "Initial a disk ..." 3
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;
#!/bin/bashecho "**********argument**********"Echo Script Name: $Echo First argument $echo second argumentecho num of argument $#echo all argument [email protected]#functionEqual (){Case $ in$)return 0;;*)Return 1;;Esac}#ifecho "**********test if****
In the actual project, Java sometimes needs to call C write out of things, in addition to JNI, I think a better way is Java call the shell. First write the C to make the executable file, and then write a shell script to execute the executable file,
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