converting centigrade to fahrenheit unix

Reply

Join Date: May 2007
Posts: 24
Reputation: cyberman111 is an unknown quantity at this point 
Solved Threads: 0
cyberman111 cyberman111 is offline Offline
Newbie Poster

converting centigrade to fahrenheit unix

 
0
  #1
Apr 22nd, 2008
Hi I am trying to write a script that converts centigrade to fahrenheit and vice versa I need to use a sub-function to perform the calculations. Can anyone help me get started on this I am kinda lost and will like help learning this thank you
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 24
Reputation: cyberman111 is an unknown quantity at this point 
Solved Threads: 0
cyberman111 cyberman111 is offline Offline
Newbie Poster

Re: converting centigrade to fahrenheit unix

 
0
  #2
Apr 22nd, 2008
OH YEa also I have afile named cen which has the tempertures as follow
1
8
22
43
89
283
120
212
1043
100
287
now i need to convert these to fahrenheit
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: converting centigrade to fahrenheit unix

 
0
  #3
Apr 22nd, 2008
Hey There,

To convert Celsius to Fahrenheit, multiply by 1.8 and add 32 degrees.

Hope that helps you get where you're going.
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 24
Reputation: cyberman111 is an unknown quantity at this point 
Solved Threads: 0
cyberman111 cyberman111 is offline Offline
Newbie Poster

Re: converting centigrade to fahrenheit unix

 
0
  #4
Apr 22nd, 2008
nope dpesnt help me , have no clue how to sub function
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: converting centigrade to fahrenheit unix

 
0
  #5
Apr 22nd, 2008
Hey There,

If you're using bash, you can just do this (pseudocode to follow)

Shell Scripting Syntax (Toggle Plain Text)
  1. function MYFUNCTION {
  2. code in here
  3. return $answer
  4. }

and then call it from the script with

Shell Scripting Syntax (Toggle Plain Text)
  1. MYFUNCTION arg1 arg2, etc

Inside the function, the arg's that you pass on the command line (arg1, arg2, etc) would be $1, $2, etc.

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 14
Reputation: Impact4ever is an unknown quantity at this point 
Solved Threads: 0
Impact4ever's Avatar
Impact4ever Impact4ever is offline Offline
Newbie Poster

Re: converting centigrade to fahrenheit unix

 
0
  #6
Apr 25th, 2008
I have the same damn homework, this is easy.

The subfunction is the datafile or the numbers you have to convert.

Place it in some type of while, for, or until loop. I found that the for loop is easiest way to go.

now to calculate the numbers you must place all of this in a $variable

Like : $c and $f

And use either let, expr, or bc to do the math for ya.

Here's a big hint. From the commandline type:

Shell Scripting Syntax (Toggle Plain Text)
  1. for i in `cat name of data file or temp file`
  2. do
  3. echo $i
  4.  
  5. done

now calculate $i (or what ever $varible you used) with the formula for centigrade and fahrenheit .

Easy!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC