I want to use bash to insert the variable $a into the cell A1 of a csv file mycsv.csv.
How do I insert a variable into a specific cell in a csv file?
I want to use bash to insert the variable $a into the cell A1 of a csv file mycsv.csv.
How do I insert a variable into a specific cell in a csv file?
Hi locoroco,
If is comma "," separated, for cell(1,1)=A1
echo "a1,b1,c1
a2,b2,c2
a3,b3,c3
a4,b4,c4" | awk -F"," 'NR==1{$1="a"$1}1'
aa1 b1 c1
a2,b2,c2
a3,b3,c3
a4,b4,c4
For cell(4,3)=C4
$ echo "a1,b1,c1
a2,b2,c2
a3,b3,c3
a4,b4,c4" | awk -F"," 'NR==4{$3="a"$3}1'
a1,b1,c1
a2 b2 c2
a3,b3,c3
a4,b4,ac4
Regards