Hi all. Using /bin/sh on an HPUX system.
I want to place a decimal in the field 2 charactors from the right (yes, converting to currency). The field lengths are variable. Here's what I'm doing:
exec < filename
while read FIELD1 FIELD2
do
FIELD1="echo $FIELD1 | sed 'syntax that will insert . 2 chars before rightmost' "
done
Thanks in advance!!!!!
echo '12345' | sed 's/..$/.&/'
If number may be one digit only, you can use this sed command :
echo "1234" | sed 's/..$/.&/;t;s/^.$/.0&/' -> 12.23
echo "1" | sed 's/..$/.&/;t;s/^.$/.0&/' -> .01
On my AIX box, i have a problem with the 't' command inside sed (all the string after t is considered as being the label to branch to). If you have the same problem, you can remove the 't;' part.
Jean-Pierre.
vgersh99, you my friend, are a superior being.
Thanks!