> > > Hello all,
> > > I need to change the format of a line and
> want to use sed:
> > > input:
> > > item1 | 123.670,00-| 345.760 | text1
> > > I want to change the item 123.670,00- to -
> 123.670,00 so
> > > the output would be:
> > > item1 | -123.670,00 | 345.760 | text1
...
> $ cat xx
> item1 | 123.670,00-| 345.760 | text1
> $ sed 's/\([0-9.,]*\)-/-\1/' xx
> item1 | -123.670,00| 345.760 | text1
You may want to tag a 'g' on the end of that, in case the input has two fields
with the trailing negative that you want to change to a leading negative:
$ cat xx
item1 | 123.670,00-| 345.760 | text1
item1 | 123.670,00-| 345.760-| text1
$ sed 's/\([0-9.,]*\)-/-\1/g' xx
item1 | -123.670,00| 345.760 | text1
item1 | -123.670,00| -345.760| text1
Or if all the number fields have leading spaces:
$ sed 's/ \([0-9.,]*\)-/-\1 /g' xx
item1 | -123.670,00 | 345.760 | text1
item1 | -123.670,00 | -345.760 | text1
Cheers...
Bruce
--
Bruce Elrick, Ph.D. Saltus Technology Consulting Group