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 master file.
file 1:
Id,city,name ,location
1,NA,JACK,CA
file 2:
ID,city,name,location
2,NY,JERRY,NY
output:
Id,city,name,location
1,NA,JACK,CA
2,NY,JERRY,NY
Currently I am using this code:
ls *.csv | xargs -n 1 tail -n+2 > master.csv
This code will merge the files perfectly , but as I need the header of the first file, this will not give me the header.
What should I do?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…