Flow control statements (if) in Shell, with super-full script exercises

Script exercise
Exercise 1: Write a script to determine whether the current user is root. If it is root, output "the user is root"; if not, output "the user is not root"
Insert picture description here
Insert picture description here

Exercise 2: Write a script to determine whether the ip entered after the script can be pinged
Insert picture description here
Insert picture description here

Exercise 3: Write a script to determine whether the process entered after the script exists
Insert picture description here
Insert picture description here

Exercise 4: Write a script to determine whether the software entered after the script is installed, if not installed, install it.
Insert picture description here
Insert picture description here

Exercise 5: Determine whether the current release version number is 6, and whether the minor version number is greater than or equal to 2
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42958401/article/details/108485558