My file is a comma delimited file and text qualifier is ~, but my requirement is to find and replace comma delimited file with |(pipe) delimited file and remove text qualifier ~ with nothing, however, I should not remove quote or double quotes or any special character within the data present in text qualifier. eg: ~abc",~ I need it as abc",
Below is the content of my source file and the way i expect the output or manipulated file to be.
364034,2015652205,26722,2015,4,~C25753-4~,~TC25753,~,~2WD Double Cab 144.2" SLT,~,~Y~,40506.16,43555.00,1095.00,~043,005,006,007,003,008,016,041,012,029,068,027,028,033~,3,~2WD Double Cab 144.2"~,~SLT~,6,4,~N~,~S~,~N~,~S~,~N~,~N~,~N~,~~,~ ~,~Confirmed~,~w2015k65m22t5~,~Sierra 2500HD~,~Double Cab Standard Box 2-Wheel Drive SLT~,~Rear Wheel Drive~,~Extended Cab Pickup - Standard Bed~
After cleansing I need the file like this:
364034|2015652205|26722|2015|4|C25753-4|TC25753,|2WD Double Cab 144.2" SLT,|Y|40506.16|43555.00|1095.00|043|005|006|007|003|008|016|041|012|029|068|027|028|033|3|2WD Double Cab 144.2"|SLT|6|4|N|S|N|S|N|N|N|| |Confirmed|w2015k65m22t5|Sierra 2500HD|Double Cab Standard Box 2-Wheel Drive SLT|Rear Wheel Drive|Extended Cab Pickup - Standard Bed
I tried sed -i -e with multiple options but the output is not 100% right.
I tried following but it's not giving right result that i wanted
sed -i -e 's/,~/|/g' file_name sed -i -e 's/~,/|/g' file_name sed -i -e 's/~//g' file_name sed -i -e 's/\([0-9],[0-9]\)/|/g' file_name sed -i -e 's/\r//g' file_name