歡迎您光臨本站 註冊首頁

請幫我看看這個script

←手機掃碼閱讀     火星人 @ 2014-03-24 , reply:0

剛開始學linux,編了一個script,但一直運行不過去,請幫我看看是怎麼回事?
下面是script:

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin/:usr/local/sbin:~/bin
export PATH
read -p "input the file name:" filename
read -p "input the 1st number:" rec_stn
awk '{for static in $1 $2 $3 $4 $5 $6
do
print $rec_stn "\t" $static "\n"
rec_stn=$(( rec_stn+1 ))
done}' $filename

系統報錯是:
awk: cmd. line:1: {for static in $1 $2 $3 $4 $5 $6
awk: cmd. line:1: ^ syntax error
awk: cmd. line:4: rec_stn=$(( rec_stn+1 ))
awk: cmd. line:4: ^ syntax error

請問我錯在哪了?

另外,還有一個script,這個雖然能運行不報錯,但也有問題:
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin/:usr/local/sbin:~/bin
export PATH
read -p "input the file name:" filename
read -p "input the 1st number:" rec_stn
awk '{printf "%10s %10s\n",rec_stn,$1}' $filename

這個的問題是能正確顯示出變數$1,但變數$rec_stn始終顯示不出來,請問這又是哪出問題了?

[火星人 ] 請幫我看看這個script已經有486次圍觀

http://coctec.com/docs/linux/show-post-141614.html