0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

共通のヘッダを持つファイルを結合する小技

Last updated at Posted at 2019-10-21

#やりたいこと

1.dat
head1 head2 head3
1 2 3
4 5 6
2.dat
head1 head2 head3
7 8 9
10 11 12
3.dat
head1 head2 head3
13 14 15
16 17 18

↑こういったファイル群を

↓こうする

merged.dat
head1 head2 head3
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18

#方法

$ awk 'NR==1 || FNR!=1' [1-3].dat > merged.dat
# 処理しているファイル全体における最初の行(ここでは"1.dat"のヘッダ) or 各ファイルの最初の行以外を出力する。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?