bash-3.00$ more eof.sh
#!/bin/bash
price=2000
cat << EOF
John said, As he looked over the amount, He'd say
the price of $price is okay and He'll give \$1000 to begin with.
EOF
echo
echo "I have \$400 in the bank."
echo
Lets run the script
bash-3.00$ ./eof.sh
John said, As he look over the amount, He'd say
the price of 2000 is right and He'll give $1000 to start.
I have $400 in the bank.
bash-3.00$
Shell Scripting examples.
Monday, September 24, 2012
Friday, September 21, 2012
Converting the Celcius degrees to Fahrenheit
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
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
Subscribe to:
Comments (Atom)