- 论坛徽章:
- 0
|
我遇到一个很奇怪的问题,就是数值参数传递进入awk后,似乎awk不能很好的识别成数值,否则下面的执行结果该如何解释呢?
这个shell里头我想把给定的数值传递入awk里头,这里给的是100和1400,希望能够截取第三列从100到1400的所有行,但是结果是漏掉了许多行,请问这是什么原因造成的,谢谢!!
#!/bin/sh
echo " lease enter the number and press the enter button."
echo "the number :\c"
read n
lcount=1
while [ $lcount -le $n ]
do
echo "enter the Fsp,Lsp and the linename for the line$lcount :\c"
read Fsp Lsp lname
echo "$Fsp" "$Lsp" $lname
awk '{if ($3>"'$Fsp'") {if ($3<"'$Lsp'") {if( $4=="'$lname'" ) {print $0 }}}}' infile
lcount=`expr $lcount + 1`
done
exit
以下是运行结果,第三列从140到1000漏掉了许多行!!!!!!!!!!!
sgi44% ./navigation
Please enter the number and press the enter button.
the number :1
enter the Fsp,Lsp and the linename for the line1 :100.0 1400.0 C-44x
100.0 1400.0 C-44x
27966.50 999642.50 120.0 C-44x
27639.50 999245.75 140.0 C-44x
12408.69 984074.00 1000.0 C-44x
12052.41 983739.25 1020.0 C-44x
11695.69 983373.75 1040.0 C-44x
11339.00 983008.00 1060.0 C-44x
10953.19 982673.62 1080.0 C-44x
10596.50 982308.12 1100.0 C-44x
10269.50 981973.00 1120.0 C-44x
09942.50 981637.75 1140.0 C-44x
09586.00 981303.12 1160.0 C-44x
09258.69 980937.25 1180.0 C-44x
08902.19 980602.50 1200.0 C-44x
08545.50 980237.12 1220.0 C-44x
08159.19 979871.75 1240.0 C-44x
07802.50 979506.25 1260.0 C-44x
07445.59 979140.75 1280.0 C-44x
07059.31 978775.62 1300.0 C-44x
06732.19 978440.62 1320.0 C-44x
06375.31 978075.12 1340.0 C-44x
06018.81 977740.38 1360.0 C-44x
05661.91 977375.00 1380.0 C-44x |
|