In the shell of Linux
The IF statement determines which branch to execute through the relational operator to determine the true or false of an expression. The Shell has three kinds of if ... else statements:
If ... fi statement;
if ... else .
This article transferred from: http://blog.csdn.net/flowingflying/article/details/5069646
This article is also the fifth chapter of the Learning the Bash Shell 3rd Edition flow control reading notes, but we will not be limited to this. Flow
#if Else statement, divided into three kinds: if...fi; If ... else ... fi; If ... elif...else...fi#if Else FI statement syntax#if [Expression]#then# Statement to being executed if expression is true#else# Statement to being executed if expression is
In Linux shell programming, in most cases, test commands can be used to test conditions, and here's a simple introduction,For example, comparing strings, judging whether the file exists and whether it is readable, etc., usually uses "[]" to
In Linux shell programming, in most cases, test commands can be used to test the condition, here is a simple introduction, easy to use friendsFor example, comparing strings, judging whether the file exists and whether it is readable, etc., usually
Click Back to learn the path of the Linux command line and shell script12.1-Structured Command If-thenMany programs require some logical process control over the commands in shell scripts. A class of commands will cause the script to skip certain
Beginning Python from Novice to Professional, 2nd Edition, CHAPTER 8, EXCEPTIONS, Page 173:
This description in the body:
The point was that using try/except statements are in many cases much more natural (more ' pythonic ') than If/else, and you
For example, comparing strings, judging whether the file exists and whether it is readable, etc., usually uses "[]" to represent the condition test.Note: The space here is important. The space to ensure the square brackets. I have wasted a lot of
Process Control statement:The IF statement is formatted as follows:#if语句的后面是Shell命令, if the command performs a successful return of 0, the command following then is executed.
The code is as follows
Copy Code
if
#ifelse_exam. Sh script is used to check whether the input string is a current directory #!/bin/bash# test user input is empty, and then determine if the current directory exists for the file if ["$"]then echo "what are NOT NULL "if [-E" $ "]
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.