if语句
1、if..then..else...fi
1 #! /bin/bash
2 echo $PWD
3 #if judagement condition expression
4 if grep "shell" ./1.txt >/dev/null
5 #if grep "Shell" ./1.txt >/dev/null
6 then
7 echo "the string exists in in current path"
8 else
9 echo "the string dosen't exist in current path"
10 fi
andy@andy-virtual-machine:~/test_shell$ cat 1.txt
shell
andy@andy-virtual-machine:~/test_shell$
2、if...then...fi
1 #! /bin/bash
2 echo $PWD
3 #if judagement condition expression
4 if grep "shell" ./1.txt >/dev/null
5 #if grep "Shell" ./1.txt >/dev/null
6 then
7 echo "the string exists in in current path"
8 #else
9 # echo "the string dosen't exist in current path"
10 fi
andy@andy-virtual-machine:~/test_shell$ cat 1.txt
shell
andy@andy-virtual-machine:~/test_shell$