fnpd.net
当前位置:首页 >> shEll iF EliF >>

shEll iF EliF

awk ' { if ($1==1) print "A" else if ($1==2) print "B" else print "C" }' #命名为1.sh 执行方法:echo "1" | sh 1.sh 写成一行: echo "3" | awk '{if ($1==1) print "A"; else if ($1==2) print "B"; else print "C"}'

亲,帮你看了一下,没有任何问题。

if test $# -eq 0 如果脚本参数的个数是0 then echo `You must give a filename` 显示 你必须给一个文件名 elif test ! -s $1 否则,如果脚本参数的文件大小为0 then echo `no file $1` 显示,所给的参数不是一个文件 else cat $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 -----你试试

if [ expression 1 ] then Statement(s) to be executed if expression 1 is true elif [ expression 2 ] then Statement(s) to be executed if expression 2 is true elif [ expression 3 ] then Statement(s) to be executed if expression 3 ...

shell脚本中的or和C语言类似,也是用||(两个竖杠)表示or逻辑。但是在shell脚本中,有严格的执行顺序要求,前一条命令或语句返回false,||的下一条语句或命令才会执行。

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 这部分我是看的...

if [ $a = "aa" -a $b = "bb" ] || [$c = "cc" -a $d = "dd" ]; then echo "success" fi 是这个意思吗

#!/bin/bashxx=0func(){dire=${PWD%/*}echo $direfor file in $(ls);do if [ -f "$file" ] then #err1 : 写在if一行,则前加分号,如;then 否则分成两行!! i=$xx #err2 : 少了$ while [ $i -gt 0 ] #err3 : -gt 是数值比较,加引号是字符串比...

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

网站首页 | 网站地图
All rights reserved Powered by www.fnpd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com