Advertisement
shiftdot515

Celsius

Aug 1st, 2020
4,791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.38 KB | None | 0 0
  1. #!/usr/bin/awk -f
  2. # Fahrenheit = Fahrenheit = 32 + Celsius X 1.8
  3. # Celsius = (Fahrenheit - 32) / 1.8
  4. BEGIN{
  5.  print "Begin line with F or C, to convert to Celsius, or Fahrenheit."
  6. }
  7. END{
  8.  
  9. }
  10.  
  11. /^[Ff].* /{
  12.  #print "Fahrenheit to Celsius"
  13.  print (($2 - 32) / 1.8 ) " C"
  14.  
  15. }
  16.  
  17. /^[Cc].* /{
  18.  #print "Celsius to Fahrenheit"
  19.  print ( 32 + ( $2  * 1.8 )) " F"
  20. }
  21. # 4 / 5 = 1.8
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement