Unix:merge multiple CSV files with same header by keeping the header of the first file

后端 未结 4 1474
清酒与你
清酒与你 2020-12-01 00:35

I have to merge multiple CSV files with same headers. I have to keep the header of the first file and remove headers of all the other files and merge them and create one mas

4条回答
  •  鱼传尺愫
    2020-12-01 00:40

    If Perl is an option:

    perl -ne 'print if $. > 1 or ! $h; $h=1; close ARGV if eof' *.csv > master.csv

    $. is the line number.
    It is NOT reset automatically between files, so close ARGV if eof is needed.
    $h records if the header has already been printed.

提交回复
热议问题