0

I have some data with a series of values on each line like this:

49.01024263     49.13389087     49.38177387  (more numbers...)
42.71585143     43.48711477     44.25625756  (ect..)
43.18826160     43.15332580     43.13094893
30.69076014     28.74489096     26.85725970

eventually the numbers reach values less than 10, at that point I'd like to delete all the remaining numbers in that line.

so far I have this, but its returning several errors.

awk '{for (i=1;i++)do{if ($i > 10.0 ) print $i ; next ; else ; exit}}' input > output

What could I be doing wrong? Any better ways to carry out this task?

4

1 回答 1

5

试试这一行:

awk '{for(i=1;i<=NF;i++)if($i>10)printf "%s ",$i;else break;print  ""}' file

用一个例子测试:

kent$  cat f
30 20 15 9 8
50 40 30 20 7 2000
100 200 300 400 5 444

kent$  awk '{for(i=1;i<=NF;i++)if($i>10)printf "%s ",$i;else break;print  ""}' f
30 20 15 
50 40 30 20 
100 200 300 400
于 2013-08-22T09:14:53.130 回答