CSV file duplicate header row

Viewed 64

I want to copy/duplicate the first row of a CSV file. The first row is the header row that contains the name of columns. Is there any bash or shell command to do this? I researched on the internet, but, was not able to find anything helpful.

Input CSV:

column_A, column_B, column_C
1, 2, 3
4, 5, 6
7, 8, 9

Output CSV:

column_A, column_B, column_C
column_A, column_B, column_C
1, 2, 3
4, 5, 6
7, 8, 9
1 Answers

If all you want is duplicate the first line, then the following might do the trick:

sed 1p input.csv
Related