2011-10-28 15 views
1

各ファイルの最初の行と各ファイルの最後の10行を表示する出力ファイルのディレクトリがあります注文。頭と尾 - 各ファイルの先頭行と最後の10行を取得しようとしています

私はコマンドの一部を下に持っている:

私にこのような何か与える
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 

いいですが、私は取得する最初の行を含めるしたいのですがヘッダーアウトプットを試してみましたが、これまでパイプの配置方法を理解できていませんでした。

提案がありますか?

答えて

2
ls output/*Response | sort -t_ --key=2 -g \ 
    | xargs -I {} sh -c 'head -1 {}; tail {}' | less 
0

また、次を試すことができます。

ls output/*Response | sort -t_ --key=2 -g | ((head -n 1) && (tail -n 10)) | less 
関連する問題