Geeks Talk

Prepare for your Next Interview




Problem with awk

This is a discussion on Problem with awk within the Unix/Linux forums, part of the Operating Systems category; Question: Will awk perform decimal point calculaiton or not? plz help Sharif.S...


Go Back   Geeks Talk > Operating Systems > Unix/Linux

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-16-2007
Contributing Member
 
Join Date: Dec 2006
Location: India
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
sharifhere is on a distinguished road
Problem with awk

Question:

Will awk perform decimal point calculaiton or not?

plz help


Sharif.S
Reply With Quote
The Following User Says Thank You to sharifhere For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 01-16-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,007
Thanks: 0
Thanked 76 Times in 64 Posts
psuresh1982 will become famous soon enough
Re: Problem with awk

Why not?

Refer the following URL:
Awk - A Tutorial and Introduction - by Bruce Barnett

-------------------
suresh
Reply With Quote
  #3 (permalink)  
Old 01-16-2007
Contributing Member
 
Join Date: Dec 2006
Location: India
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
sharifhere is on a distinguished road
Re: Problem with awk

then wat cud be the reason for this output:-
shell
awk 'BEGIN{sum=0;}
{sum=sum+(99999.99);
print sum;
}' filed

Output
100000
200000
300000
400000
500000
600000
700000
800000
900000
1e+06
1.1e+06
1.2e+06
1.3e+06
1.4e+06
Reply With Quote
  #4 (permalink)  
Old 01-16-2007
Contributing Member
 
Join Date: Dec 2006
Location: India
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
sharifhere is on a distinguished road
Re: Problem with awk

can someone pls look in to this..
Reply With Quote
  #5 (permalink)  
Old 01-16-2007
Contributing Member
 
Join Date: Dec 2006
Location: India
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
sharifhere is on a distinguished road
Re: Problem with awk

Guys i have found the solution for the abv question..

Thanks!
Sharif.S
Reply With Quote
  #6 (permalink)  
Old 01-17-2007
Expert Member
 
Join Date: Dec 2006
Location: Chennai
Posts: 197
Thanks: 2
Thanked 16 Times in 14 Posts
Barbie is on a distinguished road
Re: Problem with awk

Whats the solution sharif?
why that occurred?
post it. we too will learn.

Last edited by Barbie : 01-17-2007 at 01:42 AM.
Reply With Quote
  #7 (permalink)  
Old 01-17-2007
Expert Member
 
Join Date: Dec 2006
Location: India
Posts: 140
Thanks: 0
Thanked 6 Times in 4 Posts
nikhil_rattan is on a distinguished road
Re: Problem with awk

Hi SHerif,

As i saw u posted a very intersting query .After that you yourself found a solution for that also. That's great but if u found a solution please share with us.

Then we also come to know about the same problem's solution.

Regards

Nikhil Rattan
Reply With Quote
  #8 (permalink)  
Old 01-17-2007
Contributing Member
 
Join Date: Dec 2006
Location: India
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
sharifhere is on a distinguished road
Re: Problem with awk

In awk there is settings parameter called OFMT which holds/defines the output format of numbers. by default its "%.6g". By increasing it we can achive desired results.

sorry guys yesterday i was with urgent task to complete, so cudn't able to post solution.

Thanks,
Sharif
Reply With Quote
  #9 (permalink)  
Old 01-17-2007
Expert Member
 
Join Date: Dec 2006
Location: India
Posts: 140
Thanks: 0
Thanked 6 Times in 4 Posts
nikhil_rattan is on a distinguished road
Re: Problem with awk

Hi,

Sheri,

That was really i nice solution with complex query.

Thanks to post solution.

Regards

Nikhil
Reply With Quote
  #10 (permalink)  
Old 01-17-2007
Contributing Member
 
Join Date: Dec 2006
Location: India
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
sharifhere is on a distinguished road
Re: Problem with awk

Hey Nikhil,

Just a change i want to mention. am sharif not sheri!!!!!!


Cheers,
Sharif
Reply With Quote
  #11 (permalink)  
Old 01-17-2007
Expert Member
 
Join Date: Dec 2006
Location: India
Posts: 140
Thanks: 0
Thanked 6 Times in 4 Posts
nikhil_rattan is on a distinguished road
Re: Problem with awk

oh oh

Yap i mistyped that


fine

cheers!!!!!


Nikhil Rattan
Reply With Quote
  #12 (permalink)  
Old 01-17-2007
Contributing Member
 
Join Date: Dec 2006
Location: India
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
sharifhere is on a distinguished road
Re: Problem with awk

No Issues Nikhil..

Cheers
Sharif
Reply With Quote
  #13 (permalink)  
Old 01-17-2007
Expert Member
 
Join Date: Dec 2006
Location: India
Posts: 140
Thanks: 0
Thanked 6 Times in 4 Posts
nikhil_rattan is on a distinguished road
Re: Problem with awk

hi,

Sorry Sharif,

I mistyped that . I will take care about that for future.


Regards

Nikhil Rattan
Reply With Quote
Reply

  Geeks Talk > Operating Systems > Unix/Linux


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Problem in Decryption ramamaru Windows 2 10-13-2008 10:19 AM
div tag problem... psuresh1982 JavaScript 3 02-03-2007 09:05 AM
Problem for my post.... psuresh1982 Suggestions & Feedback 1 12-14-2006 04:32 AM
One more Mathematical problem..? psuresh1982 Brainteasers 2 11-17-2006 07:13 AM
Postman problem. jamesravid Brainteasers 4 11-13-2006 01:04 AM


All times are GMT -4. The time now is 02:46 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved