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:

Would you like to see some more classes? Click here