Chapter 6

  1. No lines. Since the loop output is redirected to a file, nothing will appear on the screen.
  2. Four. The loop will start at 8 and continue until it reaches 12, it will match the condition which is greater than or equal, and it will break the loop.
  1. The problem is with the comma in the for loop definition. It should be semicolon instead. So the correct script should be as follows:
#!/bin/bash 
for (( v=1; v <= 10; v++ )) 
do 
echo "value is $v" 
done 
  1. Since the decrement statement is outside the loop, the count variable will be the same value, which is 10. It's an endless loop, it will print 10 forever, and to stop it, you need to press Ctrl + C.

Get Mastering Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.