Sample Header Ad - 728x90

Add a header field, and the file's name at the end of the data lines, for all the csv files in a folder

-1 votes
3 answers
2254 views
I want to add filename (without extension) at the end for all the lines for all the csv files in a folder. All the files are having the same header. Let's say I have two files a.csv and b.csv in a folder. a.csv contains (first line is a header) num1,num2,num3 1,2,3 b.csv contains (first line is a header) num1,num2,num3 4,5,6 I want a.csv file to be (first line is a header) num1,num2,num3,filename 1,2,3,a I want b.csv file to be (first line is a header) num1,num2,num3,filename 4,5,6,b How can I do it in Unix?
Asked by Thomas (39 rep)
Jul 23, 2017, 01:04 AM
Last activity: Oct 16, 2022, 04:57 PM