I have a result file that looks like this:
data data data data data...
data data data data data...
data data data data data...
#0
data data is 2
#1
data data is 2
testing data ( )
n m
256 729.44
352 1555.07
448 2649.68
#2
data data is 2
#3
data data is 2
I need to grep only the table that will always have 2 columns of n and m(it can get very long). So the output should be:
n m
256 729.44
352 1555.07
448 2649.68
I've tried using awk and grep but I can only get one line not the whole table. Any help would be appreciated it.
Assuming there is no empty lines in the table, then one can use gawk like this:
awk '$1 == "n" && $2 == "m"' RS=
It will print the block which start with n
, and m
in the two first fields.
使用AWK,您将打印“字段数”等于2的所有行:
awk 'NF == 2' data.txt
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.