bash - Unix Shell Scripts Functions -


i'm learning make little programs in shell , looking how define function uses system calculator (bc -l). show i'm trying do:

#!/bin/bash square (){ need here! } cube (){ need here! } rectangle (){ need here! } exit (){ } need here! echo "little program computes following:" echo "a) surface of square" echo "b) volume of cube" echo "c) surface of rectangle" echo "e) exit" echo "choose option want compute" read answer if [ $respuesta == "a" ] echo "what's side of square" read l` 

after line don't how calll function "eats" user's answer , display computation. things worst because after computation have ask user if wants continue or exit. if me, grateful. sorry english. i'm not native speaker.

is looking for?:

menu="some items choose from:                 a)                 b) else" sample () {     a="$1"     b="$2"     c="$3"     printf "c: %s" "$c"     echo "$a+$b" | bc     echo "$a*$b"  | bc     echo "$a/$b"  | bc }  add=$(echo "2+2" | bc) printf "added: %s\n" "$add"  echo "$menu" read -p "choose: " choice  case "$choice" in     a) sample "30" "5";;     b) sample "2" "2" "2";;     *) echo "not choice";; esac 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -