0
嗨,我正在努力解決這個簡單的程序。我無法將文本文件中的值傳遞給變量。 我被困在此:value=$(sed -n "${line}p" rpt1.txt|awk {$3}
將文本傳遞給KSH中的變量。不工作
O/P:
1.sh[15]: test: argument expected
CODE:
wc `find /arbor/custom/gur/fold1`|grep -vi "total"| tee rpt1.txt
total1=`wc -l rpt1.txt`
wc `find /arbor/custom/gur/fold2`|grep -vi "total"| tee rpt2.txt
total2=`wc -l rpt2.txt`
line=1
if [ $line -le $total1 ]
then
value=$(sed -n "${line}p" rpt1.txt|awk {$3})
if [ $value -eq 512 ];
then
sed -n "${line}p" rpt1.txt|awk '{print $4}'| tee direc.txt
fi
line =$line+1
else
echo "loop over"
fi
您的代碼不太可讀。我有一種感覺,有些東西被stackoverflow解釋爲標記,這使得很難說出什麼是問題,什麼不是。無論如何,我的猜測是你在awk程序中缺少引號。 – Eric 2013-03-18 15:40:14
@Eric是對的,你需要'awk'{$ 3}''。 – squiguy 2013-03-18 15:45:14
@Eric非常感謝。 Squiguy你的建議工作! – greatvedas 2013-03-18 16:13:47