我有这个文本文件:
echo "Start 2A25.20090401.64809.7.HDF 6420 6751"
echo "dimensions 9249 49"
echo "New Cell"
grep "6449,34" out.2A25.20090401.64809.7.HDF.txt.text = 19.01 11.13 72.53 291
echo "New Cell"
grep "6466,35" out.2A25.20090401.64809.7.HDF.txt.text = 18.97 10.80 73.07 237
echo "New Cell"
grep "6483,08" out.2A25.20090401.64809.7.HDF.txt.text = 19.75 9.43 72.89 237
echo "New Cell"
grep "6524,14" out.2A25.20090401.64809.7.HDF.txt.text = 22.95 8.77 74.29 291
echo "New Cell"
grep "6529,38" out.2A25.20090401.64809.7.HDF.txt.text = 21.62 9.54 75.06 237
echo "New Cell"
grep "6542,06" out.2A25.20090401.64809.7.HDF.txt.text = 20.09 8.07 74.61 170
grep "6542,07" out.2A25.20090401.64809.7.HDF.txt.text = 32.25 8.11 74.64 210
grep "6543,06" out.2A25.20090401.64809.7.HDF.txt.text = 33.28 8.05 74.64 210
grep "6543,07" out.2A25.20090401.64809.7.HDF.txt.text = 43.38 8.09 74.67 210
grep "6543,08" out.2A25.20090401.64809.7.HDF.txt.text = 24.22 8.13 74.70 210
grep "6544,06" out.2A25.20090401.64809.7.HDF.txt.text = 35.81 8.03 74.67 210
grep "6544,07" out.2A25.20090401.64809.7.HDF.txt.text = 41.58 8.07 74.70 200
grep "6545,06" out.2A25.20090401.64809.7.HDF.txt.text = 36.3 8.01 74.70 120
grep "6545,07" out.2A25.20090401.64809.7.HDF.txt.text = 31.57 8.05 74.73 210
grep "6546,06" out.2A25.20090401.64809.7.HDF.txt.text = 28.49 7.99 74.73 292
echo "New Cell"
grep "6552,03" out.2A25.20090401.64809.7.HDF.txt.text = 18.92 7.74 74.83 237
echo "New Cell"
grep "6560,10" out.2A25.20090401.64809.7.HDF.txt.text = 23.2 7.83 75.26 291
echo "New Cell"
grep "6562,21" out.2A25.20090401.64809.7.HDF.txt.text = 26.74 8.19 75.61 210
grep "6563,20" out.2A25.20090401.64809.7.HDF.txt.text = 26.35 8.13 75.62 210
grep "6563,21" out.2A25.20090401.64809.7.HDF.txt.text = 42.51 8.17 75.64 200
grep "6563,22" out.2A25.20090401.64809.7.HDF.txt.text = 25.82 8.20 75.67 210
grep "6564,20" out.2A25.20090401.64809.7.HDF.txt.text = 23.08 8.11 75.65 272
grep "6564,21" out.2A25.20090401.64809.7.HDF.txt.text = 46.55 8.15 75.67 200
grep "6564,22" out.2A25.20090401.64809.7.HDF.txt.text = 36.89 8.18 75.70 200
grep "6565,21" out.2A25.20090401.64809.7.HDF.txt.text = 31.61 8.12 75.70 200
grep "6565,22" out.2A25.20090401.64809.7.HDF.txt.text = 28.85 8.16 75.73 120
echo "New Cell"
23,1 Top
我想删除第8列(编号200、210、120)小于200的ROWS,但必须保留新单元格。我已经尝试过像这样的awk:
awk '{if ($8 >= 200) print $0}' CSWoSpix.apr2009.sh >OUT1
但它并没有保留回声“New Cell”的线条。
答案1
要打印字段 8 大于 200 或包含短语 的行New Cell
,请尝试:
awk '{if ($8 >= 200 || /New Cell/) print $0}' filename
因为 print 是 awk 的默认操作,所以上面可以简化为:
awk '$8 >= 200 || /New Cell/' filename