shell脚本,用于根据文件的数量提取行的特定列

时间:2018-05-17 10:55:02

标签: linux shell

我有一个包含这样的行的文本文件

SURF96 R U X 0 60 3.62706 0.45137
SURF96 R U X 0 55 3.67206 0.42409
SURF96 R U X 0 50 3.70670 0.39284
SURF96 R U X 0 48 3.72564 0.38099
SURF96 R U X 0 46 3.75055 0.37002
SURF96 R U X 0 44 3.76541 0.35674
SURF96 R U X 0 42 3.77834 0.34287
SURF96 R U X 0 29 3.76465 0.23503
SURF96 R U X 0 28 3.79297 0.23035
SURF96 R U X 0 18 3.72477 0.14281
SURF96 R U X 0 17 3.68039 0.13168
SURF96 R U X 0 16 3.66185 0.12269
SURF96 R U X 0 15 3.64379 0.11389
SURF96 R U X 0 65 3.69763 0.27782
SURF96 R U X 0 60 3.63367 0.24766
SURF96 R U X 0 55 3.61961 0.22526
SURF96 R U X 0 50 3.65752 0.20910
SURF96 R U X 0 48 3.67834 0.20303
SURF96 R U X 0 46 3.69868 0.19672
SURF96 R U X 0 44 3.71768 0.19011
SURF96 R U X 0 42 3.73365 0.18303
SURF96 R U X 0 40 3.74317 0.17521
SURF96 R U X 0 18 3.70889 0.07740
SURF96 R U X 0 17 3.67677 0.07184
SURF96 R U X 0 70 3.55793 0.33480
SURF96 R U X 0 65 3.67170 0.33109
SURF96 R U X 0 60 3.71345 0.31261
SURF96 R U X 0 55 3.70758 0.28565
SURF96 R U X 0 50 3.70760 0.25968
SURF96 R U X 0 48 3.70246 0.24861
SURF96 R U X 0 46 3.69120 0.23680
SURF96 R U X 0 44 3.67689 0.22475
SURF96 R U X 0 42 3.66623 0.21330
SURF96 R U X 0 40 3.66527 0.20303
SURF96 R U X 0 38 3.68296 0.19475
SURF96 R U X 0 36 3.71654 0.18788
SURF96 R U X 0 34 3.75640 0.18126
SURF96 R U X 0 21 3.78782 0.11384
SURF96 R U X 0 11 3.35950 0.04691
SURF96 R U X 0 10 3.29834 0.04110
SURF96 R U X 0 75 3.64511 0.40430
SURF96 R U X 0 70 3.65321 0.37903
SURF96 R U X 0 65 3.70959 0.36290
SURF96 R U X 0 60 3.70855 0.33480
SURF96 R U X 0 55 3.65810 0.29860
SURF96 R U X 0 50 3.65148 0.27047
SURF96 R U X 0 34 3.72540 0.19145
SURF96 R U X 0 32 3.74026 0.18162

我想提取一行,在第6列中写入60并复制到新文件

1 个答案:

答案 0 :(得分:-1)

试试这个awk脚本:

awk '$6=="60"' file > new_file

它将输出第6列中包含字符串“60”的行。