additions


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users additions
# 1  
Old 06-21-2010
additions

Hi

I have a decimal number and want to add to 1 to Firstnumber ,2 to 2nd number .Please any one help
Code:
I/p

10000.0000
20000.00

Expecting o/p

10001.000
200002.00

Regards,
Akil
# 2  
Old 06-22-2010
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:

Code:
> 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..
# 3  
Old 06-22-2010
How about ...:

Code:
#!/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

Code:
[house@leonov] cat in.file
10000.0000
20000.00
[house@leonov] bash test.bash
10001.0000
20002.00

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command line additions

Evening: For quite some time I've searched for the correct procedure(S) to get LM 18.3X "live" (usb pendrive) to recognize/accept a casper-rw partiton. Here is an example of what I'm trying to do; https://www.unix.com/usbubuntu.wordpress.com/make-it-persistent/ ...only with LM 18. If... (0 Replies)
Discussion started by: 69Rixter
0 Replies

2. UNIX for Beginners Questions & Answers

Oracle VirtualBox Guest Additions installation help

Good day I recently attempted to to install Vbox Guest additions on CentOS 7.(Running on Windows 7 ) The packages downloaded fine . However when attempting to run the installer on CentOS 7 for vboxadditions_5.1.28_117968 , I received an error message written to ... (0 Replies)
Discussion started by: MrRobot
0 Replies

3. Virtualization and Cloud Computing

Error in virtualbox while instaling guest additions

Failed to open the CD/DVD image /usr/lib/virtualbox/additions/VBoxGuestAdditions.iso. Could not get the storage format of the medium '/usr/lib/virtualbox/additions/VBoxGuestAdditions.iso' (VERR_NOT_SUPPORTED). Result Code: VBOX_E_IPRT_ERROR (0x80BB0005) Component: Medium Interface: IMedium... (9 Replies)
Discussion started by: upvan111
9 Replies

4. Shell Programming and Scripting

script to find whether the difference between two files in only additions but not modifications

i basically have 2 files and sdiff of the files is given below sdiff file1 file 2 control_file < path INDEX < size 613 < mode 0444 ... (1 Reply)
Discussion started by: under_cons
1 Replies

5. Post Here to Contact Site Administrators and Moderators

proposed additions to the 'books' subforum in the 'Dummies' forum

Dear admins, Over in the "UNIX for Dummies" forum there is a subforum: "I'm new to Unix. Which books should I read?" The 2 Bash guides and the Linux guide on this page: The Linux Documentation Project: Guides Have been really useful to me. Also (though the same info can be found by... (0 Replies)
Discussion started by: mbubb
0 Replies
Login or Register to Ask a Question