Skip to Content
Mastering Linux Shell Scripting - Second Edition
book

Mastering Linux Shell Scripting - Second Edition

by Mokhtar Ebrahim, Andrew Mallett
April 2018
Beginner
284 pages
7h 3m
English
Packt Publishing
Content preview from Mastering Linux Shell Scripting - Second Edition

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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting - Second Edition

Learning Linux Shell Scripting - Second Edition

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788990554Supplemental Content