Array length
📖 Scenario: You are working on a simple script to manage a list of fruits in your kitchen. You want to know how many different fruits you have at any time.
🎯 Goal: Build a Bash script that creates an array of fruits, sets a variable to the number of fruits in the array, and then prints that number.
📋 What You'll Learn
Create an array called
fruits with exactly these values: apple, banana, cherry, dateCreate a variable called
count that stores the length of the fruits arrayPrint the value of
count to show how many fruits are in the array💡 Why This Matters
🌍 Real World
Counting items in a list is common in scripts that manage files, users, or data entries.
💼 Career
Knowing how to handle arrays and their lengths is essential for writing effective Bash scripts in system administration and automation.
Progress0 / 4 steps