PDF Version Available
This document is also available in PDF format: shellloop.pdf
The PDF version includes bookmarks for easy navigation and is optimized for printing.
Accessibility Notice
This document is also available in HTML format at:
https://aholdengouveia.name/IntroLinux/labs/shellloop.html
The HTML version provides enhanced accessibility features including keyboard navigation, screen reader support, responsive design, dark mode support, and high contrast options.
Objectives:
- Learn how to do loops in bash scripting. Become comfortable and competent with the concept of count controlled and event controlled loops and how to implement them. Learn more about why testing and commenting is important.
Complete the following problems
References, a video, a PowerPoint and some notes are available at my website https://www.aholdengouveia.name/IntroLinux/shellloop.html
How to turn in Scripts
- Testing must be submitted along with your code. You should submit a copy of the code and a screenshot or the results of your test so that I can see a successful run of your code. Every script should be tested. A script that doesn't run is worth 0 points.
- Comments should be done on EVERY line of code, (this is very bad practice in the real world, never do this for a job) so that I can see that you understand the code that you are submitting. Every line should have an explanation of what that line does. Comments are worth 5 points per script.
- For submission you need to submit a copy of your code (actual text NO screenshots of code allowed) and your successful test run of your code for every script.
Scripts
- Write a script that will echo a phrase for a given number of times. The user should generate the phrase and the number of times it is echoed. You may use read or positional parameters, but you need to include a comment about which one you picked and why. Include a comment with your name.
- Write a script that will do a countdown. The user should be able to specify what number is started with, the countdown should go to 1.
It's better to start simple and work your way up. I have a video on my Linux FAQ playlist on YouTube if you need help. Don't try and do the whole nested statements all at once, start with the basics, use my example if you want, and make small changes.
Deliverables
One file that includes all the requested information with your name, the date, and the lab title, make sure to follow the requested pattern for scripts, an example is included with the first scripting lab