开发者

Printing first four lines per key

I would like to print the first 4 lines by field 1 using awk

Input

111 1032192

111 2323476

111 1698881

111 2451712

111 2013780

112 2331004

112 1886376

112 1189765

112 1877267

开发者_StackOverflow中文版

Output

111 1032192

111 2323476

111 1698881

111 2451712

112 2331004

112 1886376

112 1189765

112 1877267

Thanks

Tony


awk '++count[$1] <= 4' input_file


($1 != curkey) { curkey=$1; i=0; }
(i < 4)        { i++; print; }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜