I would need to parse a field in a awk script to search for a special character and if exists to be replaced with "," or "/"
the awk script transforms a CSV into DAT. the Field separator defined is ; but sometimes users send a comment that contains the field separator. in order to fix this we would need to parse the COMMENT field which is NUMBER $4 and in case the field contains ; to be replaced with / or comma
here it is the file
"PAT";"TARO";"GEO";"COMMENT"
"FRT";"1256";"USA";"THIS IS A COMMENT ; AFTER COMMENT"
outcome expected
PAT TARO GEO COMMENT
FRT 1256 USA THIS IS A COMMENT / AFTER COMMENT
BEGIN {
FS = ";" ;
OFS = " " ;
print "pat taro geo comment";
}
NR==1{
next
}
{
pat= $1;
taro = $2;
geo = $3 ;
comment = $4 ;
}
if $4 contains ";" then
replace with "/"
end if;
{
print "pat,taro,geo,comment";
}
how can I do this ?
Thank you in advance