Heads and Tails - 尝试获取每个文件的第一行和最后十行
我有一个输出文件目录,我想按顺序显示每个文件的第一行和最后十行。
我已经得到了部分命令:
ls output/*Response | sort -t_ --key=2 -g | xargs tail | less
这给了我这样的东西:
==> output/Acdb_18_Response <==
150707,"SOVO","Other","","","","","","160x600",0,0,1432,0,0,1432
167493,"Asper","Other","","","","","","160x600",143200,0,0,1432,0,0
269774,"AIKA","Other","","","","","","160x600",0,1432,0,0,1432,0
342275,"Lorrum","Other","","","","","","160x600",0,0,1432,0,0,1432
347954,"Game","Other","","","","","","160x600",0,1432,0,0,1432,0
418858,"Technologies","Other","","","","","","160x600",0,1432,0,0,1432,0
24576,"Media ","Other","","","","","","300x600",0,0,1432,0,0,1432
23351," Plus","Other","","","","","","425x600",0,4296,0,0,4296,0
#rowcount=79
这很好,但我想包含第一行来获取标题。我尝试将输出连接到头部,但到目前为止我还无法弄清楚如何排列管道。
有什么建议吗?
I've got a directory of output files that I'd like to display the first line of each file and the last ten lines of each file in order.
I've got part of the command down:
ls output/*Response | sort -t_ --key=2 -g | xargs tail | less
Which give me something like this:
==> output/Acdb_18_Response <==
150707,"SOVO","Other","","","","","","160x600",0,0,1432,0,0,1432
167493,"Asper","Other","","","","","","160x600",143200,0,0,1432,0,0
269774,"AIKA","Other","","","","","","160x600",0,1432,0,0,1432,0
342275,"Lorrum","Other","","","","","","160x600",0,0,1432,0,0,1432
347954,"Game","Other","","","","","","160x600",0,1432,0,0,1432,0
418858,"Technologies","Other","","","","","","160x600",0,1432,0,0,1432,0
24576,"Media ","Other","","","","","","300x600",0,0,1432,0,0,1432
23351," Plus","Other","","","","","","425x600",0,4296,0,0,4296,0
#rowcount=79
which is nice but I'd like to include the first line to get the header. I tried tee'ing the output to head but so far I haven't been able to figure out how to arrange the pipes.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以尝试以下操作:
You can also try the following: