I try to add information to an ACV file with a shell script.
At this time I have information, my problem is that the CSV file is not empty at the beginning.
So I would like to put the new information in the second column.
But I can not find the way to do this.
Here's my code:
sed -i '1i column3' test.csv
sed -i '2i ;; 4 'test.csv
sed -i' 3i ;; 2 'test.csv
I have output
column 3
4 2
1 2
3 4
And I like it:
1 2 column 3
3 4 4
2
Do you think this is possible?
Thanks
What you should do in your example:
sed -i '1s /.*/& amp; Column 3 / 'test.csv sed -i' 2s /.*/& amp; 4 / 'test.csv
with awk (just leave the "-vOFS =, -F," part if you want to use the space as a separator):
awk -vOFS =, -F, 'NR == 1 {$ 3 = "col3"; Print;} 'test.csv awk -vOFS =, -F,' NR == 2 {$ 3 = 4; Change the first column:
awk -vOFS =, -F, 'NR == 1 {$ 1 = "print;}' test.csv
Col1 "; Print;} 'test.csv
Enter a column between 2:
awk -vOFS =, -F,' NR == 1 { Print $ 1, "nucole", $ 2;} 'test.csv
Comments
Post a Comment