Note that there are some explanatory texts on larger screens.

plurals
  1. POSomething similar to goto on linux
    primarykey
    data
    text
    <p>So I am writing a program on linux terminal and my program has two parts. The first part is division, the second part is calculating the MOD for some numbers. The way to quit the first part is to put 999 in either of the inputs to divide. </p> <p>My problem is that the user must put a second number even if the user input 999 as a first input. I was wondering if these is a thing like in windows where you can do goto :someOtherLocation in linux. This is the code:</p> <pre><code>echo "Enter the number to divide (dividend) (enter 999 to quit):" read numberOne [IF NUMBERONE = 999, JUMP TO SECONDPART] echo "Enter the number to divide (divisor) (enter 999 to quit):" read numberTwo while [ "$numberOne" -ne '999' ] &amp;&amp; [ "$numberTwo" -ne '999' ] do while [ "$numberTwo" -eq 0 ] do echo "You cannot divide by 0, please enter another number:" read numberTwo done RESULT=$(echo "$numberOne/$numberTwo" | bc -l) echo $numberOne / $numberTwo = $RESULT echo $numberOne / $numberTwo = $RESULT &gt;&gt; results.txt echo "Enter the number to divide (dividend) (enter 999 to quit):" read numberOne echo "Enter the number to divide (divisor) (enter 999 to quit):" read numberTwo done SECONDPART counter=1 totalCount=0 temporal=0 while [ "$counter" -lt '101' ] do temporal=$( expr $counter % 5) echo $counter MOD 5 = $temporal echo $counter MOD 5 = $temporal &gt;&gt; results.txt totalCount=$(echo "$totalCount+$temporal" | bc -l) counter=$(echo "$counter+1" | bc -l) done average=$(echo "$totalCount/100" | bc -l) echo The average of all the MODs is $average &gt;&gt; results.txt </code></pre> <p>So as seen above, I would like to jump from the input straight to the secondpart, if the input is 999.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload