Introduction to Commands:Condition Judgment: If the user does not exist Add user, give password and display add success; otherwise Show if no already in, no add; Variable name:1 , can contain only letters, numbers, and underscores, and cannot begin
The use of conditional expressions in shell programming
If conditionThenCommandElseCommandFi, don't forget this ending.
If statement forgets the end fiTest.sh:line 14:syntax error:unexpected End of fi
Three
(mainly the notes of the Zhaojianyu teacher of the Preach Wisdom Podcast, due to the lessons of these days and the previous C-C language and C + + almost all have learned all began to jump, here to thank Zhaojianyu Teacher)1. Abnormal captureWe
The test command is very powerful, but it is difficult to satisfy its escape requirements and the difference between string and arithmetic comparisons.
Greater than
Less than
Equals
Not equal to
If ["$a"-gt "$b"]
Conditional Judgment of Bash programmingBash Programming condition judgment: determine if the prerequisites for subsequent operations are met 1. The common judgment type of condition judgment (bash endogenous):Integer testCharacter testFile
From: http://m.jb51.net/article/56553.htm This article mainly introduced the shell script if condition judgment and the judgment condition summary, this article first gave the IF condition judgment the grammar, then gave the commonly used judgment
This article mainly introduces how to use if Shell script to program if statements. for details, refer to the if statement format.
If condition
Then
Command
Else
Command
Fi, don't forget the end.
If statements forget the final fi
Test. sh: line 14:
Testing and judging of shell scripts1. TestingGrammar:[operator condition] = = Test operator condition1) test file-level directoryType of File:F, FileLs-l # #只查看字段的第一个字符, file "-"D, CatalogueLs-ldL, Link fileLs-lC, character deviceLs-l/dev/ttyB,
I. Condition judgment of shell programming1. Integer testA. Expressions for conditional tests[Expression][[Expression]]Test expressionB. Integer comparison-EQ: Tests whether two integers are equal, such as $A-eq $B-ne: Test whether the two integers
1 about test testing, see the man documentationThe judgment of an expression(EXPRESSION) #EXPRESSION is True! EXPRESSION #EXPRESSION is FalseExpression1-a EXPRESSION2 #both is true,-o means orWhether the string is empty, equal-N string #the length
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.