Looping over files and directories
📖 Scenario: You are organizing files in a folder on your computer. You want to list all the files and directories inside it to see what is there.
🎯 Goal: Create a bash script that loops over all files and directories in the current folder and prints their names.
📋 What You'll Learn
Create a variable holding the list of files and directories
Create a variable to count the number of items
Use a
for loop to go through each itemPrint each item name
Print the total count of items
💡 Why This Matters
🌍 Real World
Listing files and directories is a common task when managing files on your computer or server. Automating this helps save time and avoid mistakes.
💼 Career
Many IT and DevOps jobs require writing scripts to handle files and directories efficiently. This skill is foundational for automation tasks.
Progress0 / 4 steps