How to convert the string to negative decimal number in ksh - unix
问题 if a particular character is found at certain position, I need to replace it with a number and make entire string as negative decimal number . for ex: if } is found at 14th position it need to be replaced with 2 and make it negative decimal number: sed -e 's/^\(.\{9\}\)}/.\12/;s/\(.\)/-\1/' <<< '123 00}000150}' output is: -.123 00}0001502 But, expected output is: 123 -00}00015.02 回答1: This will work: sed -e 's/\(.* \)\(.\{8\}\)\(.*\)}/\1-\2.\32/' <<< '123 00}000150}' \1 will have value: 123 (