# Shell Script Convert Fahrenheit to Celsius Temperature ( Celsius to Fahrenheit Temperature )

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

```#!/bin/bash
# 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 part of nixCraft shell script collection (NSSC)
# -------------------------------------------------------------------------
# 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) : "

if [ \$choice -eq 1 ]
then
echo -n "Enter temperature (C) : "
# formula Tf=(9/5)*Tc+32
tf=\$(echo "scale=2;((9/5) * \$tc) + 32" |bc)
echo "\$tc C = \$tf F"
elif [ \$choice -eq 2 ]
then
echo -n "Enter temperature (F) : "
# formula Tc=(5/9)*(Tf-32)
tc=\$(echo "scale=2;(5/9)*(\$tf-32)"|bc)
echo "\$tf = \$tc"
else
echo "Please select 1 or 2 only"
exit 1
fi```
🐧 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