[英]AWK print command for specific rows
I have millions of records in my file, what i need to do is print columns 1396 to 1400 for specific number of rows, and if i can get this in excel or notepad.我的文件中有数百万条记录,我需要做的是为特定行数打印 1396 到 1400 列,如果我可以在 excel 或记事本中得到它。
Tried with this command用这个命令试过
awk {print $1396,$1397,$1398,$1399,$1400}' file_name
But this is running for each row.但这是针对每一行运行的。
You need a condition to specify which rows to apply the action to:您需要一个条件来指定要将操作应用于哪些行:
awk '<<condition goes here>> {print $1396,$1397,$1398,$1399,$1400}' file_name
For example, to do this only for rows 50 to 100:例如,仅对第 50 到 100 行执行此操作:
awk 'NR >= 50 && NR <= 100 {print $1396,$1397,$1398,$1399,$1400}' file_name
(Depending on what you want to do, you can also have much more complicated selection patterns than this.) (根据您想要做什么,您还可以有比这更复杂的选择模式。)
Here's a simpler example for testing:这是一个更简单的测试示例:
awk 'NR >= 3 && NR <= 5 {print $2, $3}'
If I run this on an input file containing如果我在包含的输入文件上运行它
1 2 3 4
2 3 4 5
3 a b 6
4 c d 7
5 e f 8
6 7 8 9
I get the output我得到输出
a b
c d
e f
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.