title: Counting calculation operations and writing them into a file from a shell script
body: <p>guys. I'm new to Linux and shell scripting in general and I have a question. </p>
  
  <p>I have the following simple calculator: </p>
  
  <pre><code>input="yes"
  while [[ $input = "yes" ]]
  do
  
      PS3="Press 1 for Addition, 2 for subtraction, 3 for multiplication and 4 for division: "
      select math in Addition Subtraction Multiplication Division
      do
          case "$math" in
          Addition)
              echo "Enter first no:"
              read num1
              echo "Enter second no:"
              read num2
              result=`expr $num1 + $num2`
              COUNTER=COUNTER+1 
              echo Answer: $result
              break
          ;;
          Subtraction)
              echo "Enter first no:"
              read num1
              echo "Enter second no:"
              read num2
              result=`expr $num1 - $num2`
              echo Answer: $result
              break
          ;;
          Multiplication)
              echo "Enter first no:"
              read num1
              echo "Enter second no:"
              read num2
              result=`expr $num1 * $num2`
              echo Answer: $result
              break
          ;;
          Division)
              echo "Enter first no:"
              read num1
              echo "Enter second no:"
              read num2
              result=$(expr "scale=2; $num1/$num2" | bc)
              echo Answer = $result
              break
          ;;
          *)
              echo Choose 1 to 4 only!!!!
              break
          ;;
      esac
      done
  
  done
  </code></pre>
  
  <p>All I want is to be able to count the operations (meaning that for a successfull operation is +1, like "2 + 5 = 7" and some counter variable goes +1.. then something else and again +1) untill the user types something to stop the calculator. Then the counter variable (which holds the total number of operations performed) should be written inside a new file. How can I do this or can someone give me an example?</p>