Scripts with loops

Learning outcomes:

  • Use a script with a loop to explain how loops works
  • Demonstrate how to debug a script with a loop

Would you like to download my PowerPoint to follow along?

  • What is a loop
    • Loop takes care of repetitive tasks
    • Not the same as if/else or case statements
    • Use Cases
      • Move or delete files over a certain size/age/attribute
      • Number manipulation (such as increase all numbers by 1)
      • Changing whole folders of files (such as adding time stamps or changing permissions)
      • Searching for a value
      • Check computer status (such as is the server up)
    • Tutorial on Bash Scripting with code examples
  • While loops
  • For loops
    • Also called a for-each
    • Some example use cases might be if you needed to process a sequence or list of items,or work with items from another command such as cat or ls
    • For loop documentation with example code
  • Until loops

Suggested Activities and Discussion Topics:

  • Watch This Video and follow along.
  • Activity: Listen to This Podcast That was created using AI from these materials. Transcript for the Podcast What are your thoughts? Did the AI do a good job representing the materials? Did you find any mistakes?
  • Go through This AI generated study guide, what do you think? Did it capture the week materials well? How did you do on the self quiz? Do you know all the vocab used?
  • Go through This AI generated briefing document, what do you think? Did it capture the week materials well? Was there anything it missed? Do you know all the vocab used?

Would you like to see some more classes? Click here