Calculating Distance With Bash In Linux
Page 1 of 1
Calculating Distance With Bash In Linux
- Code:
#!/bin/bash
# (c)J~Net 2022
# jnet.sytes.net
#
# ./calc.sh
#
f="1.609344" # convertion factor
echo "Welcome To The J~Net Distance Calculator 2022"
echo ""
echo "Please Enter Speed In KPH"
read s
echo "You Entered $s"
echo ""
echo "Enter Time In Minutes"
read t
echo "You Entered $t"
echo ""
final=$((s * t))
#
offset='0.000001'
echo $final > file
#printf "%s+%s\n" $(tail -1 file) "$offset" | bc
read -r -n 1 output < file # read 1st char from text file
tail -c +2 file > file.txt # read everything else except 1st char from text file
last=`cat file.txt` # read a text file into a bash var
echo "Distance Is $output.$last Miles"
echo ""
echo "$s/$f" | bc > output.txt # Convert kph to mph
output=`cat output.txt`
echo "Also You Went $output Miles Per Hour!"
echo ""
rm file && rm file.txt && rm output.txt
Similar topics
» Calculating Pi With Bash On Linux
» Linux Xmessege Bash Example
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» W3M Linux BASH Commands
» Linux Xmessege Bash Example
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» W3M Linux BASH Commands
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum