I have data as
abc,defg,hijklm,op,qrs,tuv
I want this data to be converted to
\'abc\',\'defg\',\'hijklm\',\'op\',
Using awk gsub function. Here all the "," are replaced by ',' and start and the end of the line is replaced by "'".
awk
gsub
,
','
'
echo $x |awk -v q="'" '{gsub(/,/, q "&" q);gsub(/^|$/,q)}1' 'abc','defg','hijklm','op','qrs','tuv'