Default values for input in Bash scripting
📖 Scenario: You are writing a simple Bash script that asks the user for their favorite fruit. Sometimes, the user might not enter anything. You want to make sure the script uses a default fruit if the user leaves the input empty.
🎯 Goal: Build a Bash script that asks for user input and uses a default value if the input is empty.
📋 What You'll Learn
Create a variable to store user input
Set a default value if the input is empty
Print the final chosen fruit
💡 Why This Matters
🌍 Real World
Scripts often ask users for input but need to handle cases where the user presses Enter without typing anything. Using default values keeps scripts friendly and reliable.
💼 Career
Knowing how to handle default values in Bash scripts is useful for system administrators and developers who automate tasks and want to make scripts user-friendly.
Progress0 / 4 steps