I have a bash script that validates table entries. The final output value is $out which is inserted into an SQL INSERT statement which is then appended to /tmp/crew.txt. While $out is clearly comma separated there are no commas between the values in the resulting INSERT statement in /tmp/crew.txt. Why is this the case and how can it be fixed so I do have comma separated values in /tmp/crew.txt?
#!/bin/bash
out=290,'02:20:00','02:40:00',20.5,NULL
echo "${out:1}"
290,'02:20:00','02:40:00',20.5,NULL
echo "INSERT INTO tip_run (date_linkid, start_time, finish_time, weight, note) VALUES ("${out:1}");" >> /tmp/crew.txt
vi /tmp/crew.txt
INSERT INTO tip_run (date_linkid, start_time, finish_time, weight, note) VALUES ( 290 '02:20:00' '02:40:00' 20 NULL);
Thus the result in /tmp/crew.txt should be:
INSERT INTO tip_run (date_linkid, start_time, finish_time, weight, note) VALUES ( 290,'02:20:00','02:40:00',20,NULL);