shell脚本elseif
A. 闂涓涓狲hell鑴氭湰闂棰桡纴鍏充簬𨱒′欢娴嬭瘯
If hao
....
Elif buhao
...
Else
...
Fi
镓嬫満镰侊纴澶ф傛剰镐濅綘镍傦纴鍙浠ョ敤elif 濡傛灉娌℃湁灏辨槸elseif
B. shell的awk中用if..else,怎么多条件嵌套
else和if之间要有个空格
C. shell脚本if then else的问题
问题出在echo("true")或者echo("false")这一句,ftp里面不支持,你手动执行一下就知道了。
ftp>echo("true")
?Invalidcommand
ftp>help
Commandsmaybeabbreviated.Commandsare:
! debug mdir sendport site
$ dir mget put size
account disconnect mkdir pwd status
append exit mls quit struct
ascii form mode quote system
bell get modtime recv sunique
binary glob mput reget tenex
bye hash newer rstatus tick
case help nmap rhelp trace
cd idle nlist rename type
cp image ntrans reset user
chmod lcd open restart umask
close ls prompt rmdir verbose
cr macdef passive runique ?
delete mdelete proxy send
D. shell 脚本中后台调用函数结束
比面shell脚本文件:#===========test.sh! /bin/shecho_line(){ echo date echo "Wellcome to shell func!"}echo_hello(){ echo "Hello World!"}#======================shell调用两函数啊我用【./test.sh echo_hello】却没输我已经给test.sh加执行权限
请问envsetup.sh边
function gettop()
{
local TOPFILE=build/core/envsetup.mk
if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
echo $TOP
else
if [ -f $TOPFILE ] ; then
# The following circumlocution (repeated below as well) ensures
# that we record the true directory name and not one that is
# faked up with symlink names.
PWD= /bin/pwd
fi
}并没返值
调用何获取参数 T=$(gettop)
实际参数谢谢
E. shell脚本, if语句必须要有else吗
不必须,可以直接
if 【条件】
【要做的内容】
fi;
这样就可以了。也可以用else
if 【条件1】
【要做的内容1】
else if 【条件2】
【要做的内容2】
fi;
F. 鍦↙inux绯荤粺涓嬶纴缂栧啓涓涓猄hell鑴氭湰锛屼粠阌鐩樿诲叆5涓鏁存暟锛岀劧钖庢樉绀烘渶澶ф暟銆佹渶灏忔暟銆佸拰骞冲潎鏁般
#!/bin/bash
#浠绘剰杈揿叆5涓鏁帮纴鍒ゆ柇链澶у硷纴链灏忓硷纴镐诲拰
s=0
read -p "please input:" num
s=$(($s+$num))
max=$num
min=$num
avg=$(($s/5))
for i in `seq 4`
do
read -p "please input:" num
s=$(($s+$num))
if [ $num -le $min ];then
min=$num
fi
if [ $num -ge $max ];then
max=$num
fi
done
echo max:$max min:$min avg:$avg
镓╁𪾢璧勬枡锛
for寰鐜锛
涓鑸镙煎纺涓猴细
for var in item1 item2 ... itemN
do
command1
command2
...
commandN
done
鍐欐垚涓琛岋细
for var in item1 item2 ... itemN; do command1; command2钬 done;