Hi ,
This is just a honest try to start a blog where I can post the example shell scripts for reference purpose:
Following one is converting the Celcius degrees to Fahrenheit.
bash-3.00$ vi converttofh.sh
#!/bin/bash
echo -n "Please enter the value" :
read value
fah=$(echo "($value * 1.8)+32" |bc)
echo The Fahrenheit equivalent of $value is $fah
Explained:
1. Sha bang header - Path to the shell.
2. Echo statement to to enter the value in number. -n is for new line.
3. Read the input value from the keyboard.
4. Define a variable to do the calculation with inbuilt "bc" calculator in unix.
5. With the help of "echo" get the desired result printed to the screen.
Below is the out put of the screen.
bash-3.00$ ./converttofh.sh
Please enter the value :32
The Fahrenheit equivalent of 32 is 89.6
No comments:
Post a Comment