I have the following string. I would like to find the first occurrence of digits in a line, use this match to replace the NULL's.
INSERT INTO data VALUES (11,1), (NULL,2), (NULL,3), (NULL,4);
I'm really not familiar with sed or awk at all.
so in the example above this is the output i want.
INSERT INTO data VALUES (11,1), (11,2), (11,3), (11,4);
this is kinda pseudo of the issue i think awk '{ sub(/{digit}/, "NULL", capturegroup }'
while read -r line; do
name="$line"
echo $line |
awk '
match($0,/\([0-9]+/){
value=substr($0,RSTART+1,RLENGTH-1)
}
{
gsub("NULL",value)
}
1' >> converted.sql
done < test.sql