Reputation: 2260
I want to write a script that will add new columns daily to a csv sheet.
The script will run daily and will append to csv file. Now how to edit csv file ? Edit will be via awk or sed commands. I will use this csv file to send mail to users and it will be used in excelsheets.
I have not found any relavent answers from all questions i have been through so please try to answer it .
Upvotes: 1
Views: 5555
Reputation: 77105
You can try something with awk
:
awk 'BEGIN{FS=OFS=","}{$NF=$NF",new_stuff"}1' csv
$ cat csv
1,shoes,red
2,apple,black
3,fog,blue
4,elephant,gray
5,monkey,green
$ awk 'BEGIN{FS=OFS=","}{$NF=$NF",new_stuff"}1' csv
1,shoes,red,new_stuff
2,apple,black,new_stuff
3,fog,blue,new_stuff
4,elephant,gray,new_stuff
5,monkey,green,new_stuff
Upvotes: 1
Reputation: 3389
so you want something like that :
sed 's/\(john mayers.*\)$/\1\,hallo/' file
file:
john mayers ,hi ,hello
jack bauer ,yo ,wasup
output:
john mayers ,hi ,hello,hallo
jack bauer ,yo ,wasup
Upvotes: 0