ints.txt is a file containing some integer values.
$ cat ints.txt
234
2
67
9812
12890
I had to convert all the values to 2 decimal points to right.
i.e. required output:
2.34
.02
.67
98.12
128.90
Sed solution:
$ sed 's/..$/.&/;t;s/^.$/.0&/' ints.txt
Can be done just by dividing by 100 using awk like this
$ awk '{print $0/100}' ints.txt
2.34
0.02
0.67
98.12
128.9
2 comments:
while read num; do dc -e "2k$num 100/p"; done < ints.txt
could do this without invoking "dc" more than once (GNU dc):
< ints.txt dc -e "2k[q]sq[?z0=q100/pcl?x]s?l?x"
Post a Comment