Sponsored Content
Full Discussion: Can someone please help....
Top Forums Shell Programming and Scripting Can someone please help.... Post 302846679 by Scrutinizer on Sunday 25th of August 2013 12:24:57 PM
Old 08-25-2013
Hi, welcome to these forums. Could you elaborate some more on what your problem is and what you are trying to accomplish?

Perhaps something like this may give you some idea:
Code:
echo 'enter "num1" operation "num2" (space separated)'
while read num1 operation num2
do
  case $operation in
    (+)  result=$((num1 + num2)) ;; 
    (-)  result=$((num1 - num2)) ;; 
    (\*) result=$((num1 * num2)) ;; 
    (/)  result=$((num1 / num2)) ;; 
    (*)  result="Invalid input"
  esac
  printf "%s\n" "$result"
done

 
All times are GMT -4. The time now is 09:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy