次のテキストファイルがあります。
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
200より小さい列8(数字200、210、120)の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
印刷はawkの基本的な操作なので、上記の内容を次のように簡素化できます。
awk '$8 >= 200 || /New Cell/' filename