Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Remove '.' from file for numbers ending in '.'

$
0
0
Hi,
I have numerous files which have data in the following format

Code:

A|B|123.|Mr.|45.66|33|zz
L|16.|33.45|AC.|45.

I want to remove decimal point only if it is last character in a number.
O/p should be

Code:

A|B|123|Mr.|45.66|33|zz
L|16|33.45|AC.|45

I tried this
Code:

sed -e 's/.|/|/g'
Problem with above is that it removes the '.' for Mr.
Also I want to remove '.' for last field in second line 45. should be 45
Basically any numeric filed which has a decimal but no number after decimal, should have decimal point removed

Thanks

Viewing all articles
Browse latest Browse all 16232

Trending Articles