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;