Temperature is a physical property of a system that underlies the common notions of hot and cold; something that is hotter generally has the greater temperature. Temperature is measured with thermometers that may be calibrated to a variety of temperature scales. In most of the world , the degree Celsius scale is used for most temperature measuring purposes. The Celsius scale, is commonly used for scientific work. The Fahrenheit Scale is used in USA and some other countries.

Temperature Conversions

  • Fahrenheit to Celsius temperature conversion formula : C = (F – 32) x 5/9
  • Celsius to Fahrenheit temperature conversion formula : F = (C x 9/5) + 32

See wikipedia article about temperature conversion formulas.

Temperature Conversions Shell Script

# Shell script to convert Fahrenheit to Celsius Temperature or Celsius 
# to Fahrenheit Temperature
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Fahrenheit and Celsius Temperature Scales more info:
# http://en.wikipedia.org/wiki/Temperature_conversion_formulas
# --------------------------------------------------------------------
echo "*** Converting between the different temperature scales ***"
echo "1. Convert Celsius temperature into Fahrenheit"
echo "2. Convert Fahrenheit temperatures into Celsius"
echo -n "Select your choice (1-2) : "
read choice
if [ $choice -eq 1 ]
	echo -n "Enter temperature (C) : "
	read tc
	# formula Tf=(9/5)*Tc+32
	tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
	echo "$tc C = $tf F"
elif [ $choice -eq 2 ]
	echo -n "Enter temperature (F) : "
	read tf
	# formula Tc=(5/9)*(Tf-32) 
	tc=$(echo "scale=2;(5/9)*($tf-32)"|bc)
	echo "$tf = $tc"
	echo "Please select 1 or 2 only"
	exit 1
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics via:
Category List of Unix and Linux commands
Disk space analyzers ncdu pydf
File Management cat
Firewall Alpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilities NetHogs dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searching grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN Alpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Jazz May 16, 2017 @ 6:24

    For everyday usage ….the sensible way,…….

  • mel Dec 9, 2009 @ 18:22

    The math is wrong.

  • celsius to fahrenheit Jul 31, 2008 @ 9:10

    thank you for this script, will help us very much

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.