File test: Need to add brackets
Whether the-e file exists
Whether the-f file is a normal file
Whether the-D file is a directory
-R file is readable for the current user
-W File Write
-X File Execution
Combination test:
-A and relationship
-O or relationship
! Non-relational
Writing:
If [$A-ge 4-a $A-lt 7]
If [$A-ge 4] && [$A-lt 7]
Greater than or equal to 4 and less than 7
If [$A-ge 4-o $A-lt 4]
If [$A-ge 4] | | [$A-lt 4]
Greater than or equal to 4 or less than 4
Fuzzy matching =~
Integer containing 4 in 1-100
i= ' seq 1 100 '
V=4
[[$I =~ $V]]
Judging file scripts (normal, directory, or other)
Read-p "Please input a file:" N
If [-F $N];then
echo "$N is Putong"
elif [-D $N];then
echo "$N is Mulu"
Else
echo "Bu Cunzai huo Feifa"
Fi
Exercise: Write two numbers to calculate the result of multiplying the two numbers together
#!/bin/bash
#
If [$#-lt 2];then
echo "Qing Xie Chu lia ge Shuzi"
Exit 8
Fi
echo "He wei $[$1+$2]"
echo "Ji Wei $[$1*$2]"
This article is from the "you and I Walk" blog, please be sure to keep this source http://ondali.blog.51cto.com/6650368/1615953
Bash--file test, string comparison