sed problem

Hi all

In input file I have records like this:

0,1,0,87,0,0,"6,87","170,03",0,"43,5",0,0,0,0,"6,87","126,53"

and in output file I need that these records transforms in :

0 1 0 87 0 0 6,87 170,03 0 43,5 0 0 0 0 6,87 126,53 

Could you help me in this case? Please

one way:

#  sed -e 's/,/ /g' -e 's/\"\([0-9]*\) \([0-9]*\)\"/\1\,\2/g' infile
0 1 0 87 0 0 6,87 170,03 0 43,5 0 0 0 0 6,87 126,53

HTH

1 Like

Another way, which is pretty similar to Tytalus' approach:

$ echo '0,1,0,87,0,0,"6,87","170,03",0,"43,5",0,0,0,0,"6,87","126,53"' |\
> sed 's/"\([0-9]*\),\([0-9]*\)"/\1.\2/g;s/,/ /g;s/\./,/g'
0 1 0 87 0 0 6,87 170,03 0 43,5 0 0 0 0 6,87 126,53
$

I promise I had my approach ready before I saw Tytalus' one :slight_smile:

1 Like

2pseudocoder
thanks a lot

---------- Post updated at 10:23 PM ---------- Previous update was at 10:21 PM ----------

2Tytalus
thanks a lot