http://tldp.org/LDP/abs/html/Advanced Bash Scripting Programming GuideAn in-depth exploration of scripting language artThis tutorial does not assume previous scripting or programming knowledge, but progresses quickly toward an intermediate/
At the beginning of the new year, the knowledge base of open source class is online. Early on, the Linux command Encyclopedia/bash Reference, Advanced Bash Scripting Programming Guide, is available in two series. Other materials are on the line.Among them, the Advanced
Advanced Bash-scripting Guide (19th): maximum common divisor of two integers, bashscripting
The example selected in this article is from the book "Advanced Bash-scripting Gudie", translated by Yang chunmin Huang Yi
1 #! /Bin/
Advanced Bash-scripting Guide (17): use more to view gzip files,
The example selected in this article is from the book "Advanced Bash-scripting Gudie", translated by Yang chunmin Huang Yi
1 #! /Bin/
Advanced Bash-scripting Guide (15th): Test broken link files (broken link ),
The example selected in this article is from the book "Advanced Bash-scripting Gudie", translated by Yang chunmin Huang Yi
1 #/bin/
Advanced Bash-scripting Guide (18): [[] and [] some special cases, bashscripting
The example selected in this article is from the book "Advanced Bash-scripting Gudie", translated by Yang chunmin Huang Yi
For example, [1-eq 1] [-
Case statement and scripting Options Advanced Detail the control flow in the process-oriented programming language (that is, the statements in the program) is executed sequentially by default.Control structure of programming language there are three categories:1, sequential structure2, select structure(1) If statementIf statement for a single branchFormat: If Condition1;thenExpression...FiIf statement for t
Advanced Bash script, classic usage and cases, advanced bashIn linux, Bash scripts are very basic knowledge. You may feel very high when you listen to the scripts. Just like starting from the beginning, you may feel that script writing is a great tool. Although complicated scripts are very easy to understand, when we m
Little exercise: Write a scriptDetermine if a user's default shell is bash on the systemIf there is one, it shows how many such users will otherwise show no such user#!/bin/bash#grep "bash$"/etc/passwd >/devnullCode=$?If [$CODE-eq 0]; Thenusernu= ' grep ' bash$ '/etc/passwd | Wc-l 'echo "The number of
, form.html
(2) Write a request to receive the CGI, the above action has been specified, that is, form_test.sh
#!/bin/bash
echo ' content-type:test/html ' echo ' echo
$QUERY _string
2 implement a return HTML page with the title and content of Hello worldThe page effect returned is as follows:
The implementation method, also implements a CGI, just returns the content is an HTML:
#!/bin/bash echo '
What is Bash shell script programming?A: There are multiple shells in Linux, and the default shell for CentOS and Redhat is the bash shell. As for shell scripts, this is a bit like (. bat file) for batch files inside the Windows operating system. I wonder if you remember the philosophical thinking of Linux? There are two points: a single application consisting of a multitude of purposes: A program that only
Transfer from http://blog.chinaunix.net/uid-20328094-id-95121.htmlA very good bash scripting tutorial, at least not in contact with bash can read!Create a scriptThere are many different shells in Linux, but usually we use Bash (Bourne again shell) for Shell programming because bash
Bash (GNU Bourne-again Shell) is a Unix shell written for the GNU program, which is the default shell used by many Linux platforms.Variables for bash scripting:1. $BASHRepresents the path of a bash binary program fileEg: Edit the bash file, such as 1.sh, in which the followi
used with variable names, and if the loop body does not include a variable name, a dead loop may occurHow the list is generated:1) Give a direct2) List of pure integersSEQ: Output An integer listseq [First [INCREMENT]] Last3) curly braces unfold{first.. Last}4) return value of the execution result of the command5) GLOBBING6) references to certain variables: [email protected], $*Features of the For loop:1. There is almost no cycle of death;2. The entire list needs to be loaded into memory during
addition to Shebang, the # occupies the absolute beginning of the content, is the comment line, the interpreter ignores the contents of such a line;3. The explanation ignores all blank lines in the script;4. Lots of commands and keywords (if,else,then,do,while,for, ... )Note: Once the shell script runs in the current shell according to Shebang's instructions, an interpreter (child shell) is opened explaining the execution of the code, and the contents of the shell script are implemented in a ch
; Thenuserdel-r $USER [$DEBUG-eq 1] ECho "Delete $USER finished." else[$DEBUG-eq 1] echo "$USER not exist." Fidonefi Exercise: Write a script showlogged.sh, which uses the format: Showlogged.sh-v-c-h|--help where the-h option can only be used alone to display help information; the-C option displays the number of users logged on on the current system If you use the-V option at the same time, both the number of simultaneous users logged in and the information about the logged-on user are display
Bash shell scripting Getting Started (iii) cycleWhat is loop execution?To run a code segment repeatedly multiple timesHow many times to run repeatedly:Number of cycles known beforehandNumber of cycles unknown beforehandThere are entry conditions and exit conditionsRelated commands: For, while, Until,selet,Use for commandRole:Assigns the element in the list to the "variable name" in turn; The loop body is ex
True when the length of a string is greater than 0
-Z str1
True when the length of a string is 0
Str
True when the string is non-empty
As an example, compare strings to test the user id:If ["$ (whoami)"! = ' root ']; Thenecho "You had no permission to run $ as Non-root user."Exit 1;Fi
Numeric comparison (integer)
operator
Compare Results
Num1-eq num2
Two numbers equal to True
Learn more about the character test of Linux and the practice of bash scriptingOne, character test options= =: Tests whether two strings are equal, equals true, and not equal to false.! =: Tests whether two strings are unequal, unequal to true, and equal to false.-N String: Tests whether the specified string is empty, NULL is true, and is not NULL for false.-Z String: Tests whether the specified string is not empty, is not empty, is true, and Null is
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.