Why variables store and reuse data
📖 Scenario: Imagine you are organizing a small event and need to keep track of the number of guests invited. Instead of typing the number every time, you want to store it once and reuse it easily in your script.
🎯 Goal: You will create a bash script that stores the number of guests in a variable, updates it, and then prints the final number. This will show how variables help store and reuse data in scripts.
📋 What You'll Learn
Create a variable called
guest_count with the initial value 10Create a variable called
new_guests with the value 5Add the value of
new_guests to guest_count and store the result back in guest_countPrint the final value of
guest_count using echo💡 Why This Matters
🌍 Real World
Event planners and organizers often need to keep track of numbers like guests, seats, or items. Using variables in scripts helps automate these tasks.
💼 Career
Knowing how to store and reuse data with variables is a basic skill for automation, system administration, and scripting jobs.
Progress0 / 4 steps