I have file "report.csv" . This report is generated based on few parameters
which can range from 1-10. So the report.csv has all the parameters printed in
it first and then , the main header and the data. Now I need to process
this file with the header and data and exclude all the parameters. The file looks like this:
para_1: abc
para_2: def
para_3: ghi
.
.
.
para_n: xyz
Customer_Name, Customer_Number, .....
Jon Doe,19923
Adam Plak,19985
.
.
.
I used below command to get the position of the Column header
This gives me the position
grep -n "Customer_Name" report.csv | cut -d : -f1
(let's say) 13
. Then I use this command to copy to another file and use the new file
sed '1,13d' report.csv >> report_test.csv
however i need to make it dynamic , like
$var1 = grep -n "Customer_Name" report.csv | cut -d : -f1
$var2 = d
sed '1,$var1$var2' report.csv >> report_test.csv
can you experts please help achieve this in Shell Script?
sed
likesed '1,/Customer_Name/' report.csv >> report_test.csv
? – Philippos Jun 24 '19 at 08:49