+ 1
Bash Scripting
I just started Kali and I'm learning bash scripting at the moment. Please how can I use float numbers? I'm really confused about the concept.
4 Respostas
+ 3
Sharon Ureh Odu It seems u have a fundamental misunderstanding of what shell scripting is. Its not a general purpose language like C or python, its not there to create programs, games, etc.. Shell scripting is to automate tasks in the terminal.
For ur question specifically, shell scripting would act as glue between programs that actually do work. Like u can use bc or python to make the calculation (or any other tool).
As a real world example, there is a shell script (package on linux) that creates a menu for passwords (from pass), so u can search them up and use quickly. How is this done? It uses a C program/package (dependancy) that does the same thing for programs, and just uses it as a selector, piping in the options and copying the output.
+ 1
bash does not support floating-point arithmetic by default, but you can use external tools for this
0
please what kind of external tools?
Let's say I'm trying to calculate the area of a trapezium
echo "Area of a Trapezium"
read -p "length on one side" a
read -p "length on the other side" b
read -p "height of the trapezium" h
echo "Area of trapezium: $(( 1/2 * (a+b) * h" | bc))
What's wrong with the code?
I know it's incorrect but I don't know how to correct it.