A, Shell conditional statement (if usage)
If statement structure [IF/THEN/ELIF/ELSE/FI]
Copy Code code as follows:
If condition test statement
Then
Action
[Elif condition
Action
Else
Action
]
Fi
If
I. Shell Condition Statement (if usage)
If statement structure [if/then/Elif/else/FI]
If condition test statement
Then
Action
[Elif Condition
Action
Else
Action
]
Fi
If you are not clear about the conditional test statement, refer to:
01. Judging by File type = Common-D,-E,-FTwo types of formats:TEST-E/root/install.log = Common[-e/root/install.log] = both spaces must haveExample: [-d/root] && echo "Yes" | | echo "No": Determine if the file exists and whether it is a directory
Case statements are useful for applications where multiple branches are required.The case Branch statement is formatted as follows:Case variable name inMode 1)Command sequence 1;;Mode 2)Command Sequence 2;;*)Sequence of commands executed by
1, print the system load every 3 seconds#!/bin/bashwhiletruedo uptime sleep3 Done2, save the monitoring results to a file, execute in the background, and then monitor the file changes with Tail-fSH while. sh &[112867#!/bin/bashwhiletruedo
File system access list:Facl:filesystem Access Control ListSave additional access control permissions with file extensionsOwner>group>otherOwern>facl,user>group>facl,group>otherSetfacl-M: SetU:uid:permG:gid:perm-X: CancelU:uidG:gid[Email protected] ~
The Linux shell has its own process Control statement, which includes a conditional statement (if), a looping statement (For,while), and a SELECT statement (case). I'll use the example below to illustrate how each statement is used.One, Shell
1, determine whether a number is in the one-way.#!/bin/Bashread-P"pls input a number:"N Case "$n" inch 1) Echo "variable is 1" ;; 2) Echo "variable is 2" ;; 3) Echo "variable is 3" ;; *) Echo "pls
Conflict 1: Linux and Windows are completely different.
You will be surprised by the similar complaints from so many people about Linux. They rush to Linux and want to find a free and open-source version of Windows. Generally, this is what the avid
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.