Hi
I have a decimal number and want to add to 1 to Firstnumber ,2 to 2nd number .Please any one help
I/p
10000.0000
20000.00
Expecting o/p
10001.000
200002.00
Regards,
Akil
Hi
I have a decimal number and want to add to 1 to Firstnumber ,2 to 2nd number .Please any one help
I/p
10000.0000
20000.00
Expecting o/p
10001.000
200002.00
Regards,
Akil
Not sure if this is exactly what you want, as in your question the nuber of trailing zeroes changes from i/p to o/p, but, something like:
> cat infile
10000.0000
20000.00
> awk '{printf("%f\n",$1+NR)}' infile
10001.000000
20002.000000
or
> awk '{printf("%.3f\n",$1+NR)}' infile
10001.000
20002.000
Should get you heading in the right direction and give you something to play about with and get to your liking..
How about ...:
#!/bin/bash
LC=1
while read DV
do
LV=$( echo $DV | cut -d '.' -f 1 )
RV=$( echo $DV | cut -d '.' -f 2 )
LV=$(( $LV + $LC ))
OV=${LV}.${RV}
echo "$OV" >> out.file
LC=$(( $LC + 1 ))
done < in.file
cat out.file
exit 0
# finis
[house@leonov] cat in.file
10000.0000
20000.00
[house@leonov] bash test.bash
10001.0000
20002.00