www.kzwk.net > 编写一个shEll程序,使用iF…thEn…ElsE结构编写一个...

编写一个shEll程序,使用iF…thEn…ElsE结构编写一个...

简单的写了个,不考虑异常输入 #!/bin/bash if [ $1 -gt 100 ] then echo "the number is greater than 100" elif [ $1 -lt 10 ] then echo "the number is smaller than 10" else echo "the number is between 10 and 100"

if [ $1 -gt 100 ] ; then echo "the number is greater than 100" else if [ $1 -lt 10 ] ; then echo "the number is smaller than 10" else echo "the number is between 10 and 100" fi fi

一行一行写就行啦。 你这不就是 语句1 语句2 语句3

$pid存在且不为0为true

问题出在echo("true") 或者echo("false")这一句,ftp里面不支持,你手动执行一下就知道了。 ftp> echo("true")?Invalid commandftp> helpCommands may be abbreviated. Commands are:! debug mdir sendportsite$ dir mget put sizeaccount disco...

你为什么要做两个判断?我看你的意思就是如果test19这个file不存在然后创建。 为什么之前还要做一个-e的判断?如果你只是判断test19,写这一句不就足够了。 if [ ! -f test19 ] then touch test19 fi

#! /bin/bash echo '请输入一个成绩' read n if [ $n -ge 90 ] then echo "优" else if [ $n -ge 70 ] then echo "良" else if [ $n -ge 60 ] then echo "及格" else if [ $n -le 60 ] then echo "不及格" fi fi fi fi

#!/bin/bashif [ $# -lt 1 ];then echo "usage $0 [path or file]" exit -1fiif [ "$1" = "/root" ];then ls -a $1 | tee 13out else echo "第一个位置参数不是/root目录!" exit -2fiargc=0for i in $@do argc=$(($argc+1)) if [ $argc -eq 1 ]...

echo "你继续吗?Y or N" read ANSWER if [ “$ANSWER” = “Y” -o “$ANSWER” = “y” ] ; then echo "你选择了$ANSWER"; elif [ “$ANSWER” = “N” -o “$ANSWER” = “n” ] ; then echo "你选择了$ANSWER"; else echo "输入错误" exit fi -----你试试

#!/bin/sh a=`du -s yourfile.txt | awk '{print $1}'` if [ $a -eq 1024 ] then echo "OK" else echo "ERROR" fi

网站地图

All rights reserved Powered by www.kzwk.net

copyright ©right 2010-2021。
www.kzwk.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com