Hello I'm trying to add column headers in my CSV file with awk in terminal.
Currently displays:
Michael, [email protected], Seattle, Washington, detail1, detail2, detail3
Desired format:
Name, Email, City, State, more1, more2, more3etc
Michael, [email protected], Seattle, Washington, detail1, detail2, detail3,
Have tried something like this, but I end up getting "Illegal Statement at Source line 2":
awk 'BEGIN {FS=",";OFS=","; print "Rating,Restaurant,Address,Landline,Mobile,Cuisine,Website,LatDD,LonDD"}
NR >1 {print ",",,,",",",", }' Restaurants.txt > Restaurants_newer.txt
this will do
sed '1iName, Email, City, State, more1, more2, more3etc' file > newfile
can be done in place too
sed -i '1iName, Email, City, State, more1, more2, more3etc' file
or
{ echo 'Name, Email, City, State, more1, more2, more3etc'; cat file; } > newfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With