-
两个整数之间比较查看全部
-
两个文件之间进行比较查看全部
-
根据文件类型判断查看全部
-
#!/bin/bash test=$(ps aux | grep httpd | grep -v "grep") if [ -n "$test" ] then echo "http is running" else echo "http is down" echo "http is trying to restart" /usr/local/apache/bin/apachectl start &>/dev/null test1=$(ps aux | grep httpd | grep -v "grep") [ -n "$test1" ] && echo "Service has restarted" || echo "failed" fi查看全部
-
#!/bin/bash read -p "Please input your firstnum:" num1 read -p "Please input your secondnu:" num2 read -p "please input your operation:" ope test1=$(echo $num1 | grep "[^0-9]") test2=$(echo $num2 | grep "[^0-9]") if [ -z "$num1" -o -z "$num2" -o -z "$ope" ] then echo "Input is NULL" exit 10 #查看输入是否为空 fi if [ -n "$test1" -o -n "$test2" ] then echo "Input is not number" exit 11 fi #查看输入的是否是数字 if [ "$ope" == '+' ] then result=$(($num1 + $num2)) elif [ "$ope" == '-' ] then result=$(($num1 - $num2)) elif [ "$ope" == '*' ] then result=$(($num1 * $num2)) elif [ "$ope" == '/' ] then result=$(($num1 / $num2)) else echo "Ope is error" exit 12 fi echo "$num1 $ope $num2 = $result"查看全部
-
1 #!/bin/bash 2 3 read -p "Input your file: " file 4 5 if [ -z "$file" ] 6 then 7 echo "Input is NULL" 8 exit 1 9 fi 10 11 if [ ! -e "$file" ] 12 then 13 echo "$file is not exit" 14 exit 2 15 fi 16 17 if [ -d "$file" ] 18 then 19 echo "$file is a directory" 20 elif [ -f "$file" ] 21 then 22 echo " $file is a file" 23 else 24 echo "$file is not known" 25 fi查看全部
-
case 语法查看全部
-
建立编程思想的“笨”方法 1.抄 2.补注释 3.删注释,补注释 4.看注释写代码 5.从头写查看全部
-
#逻辑与and -a #逻辑或of -o #逻辑非 !查看全部
-
字符串判断 -z 字符串 #判断是否为空,为空返回真 -n 字符串 #判断是否为非空,非空返回真 字符串1 = = 字符串2 #判断字符串是否相等,相等返回真 字符串1 != 字符串2 #判断字符串是否不等,不等返回真查看全部
-
两个文件之间进行比较 file1 -nt file2 #nt 我理解为 newer than 比……新 file1 -ot file2 #ot 我理解为 older than<br> 比……旧 file1 -ef file2 #判断文件inode是否一致查看全部
-
按文件类型进行判断 [ -e /root/instll.log ] && echo yes || echo no查看全部
-
add a large number of users one by one.查看全部
-
批量添加指定数量的用户!查看全部
-
循环打印1、2、3、4、5查看全部
举报
0/150
提交
取消