Variables, Input, and Output
Learn to declare variables, accept user input, and manage script output in shell scripts.
What are Script Variables?
In shell scripting, variables are like containers for storing data. They help make your scripts flexible and reusable.
Instead of hardcoding values, you can use variables to hold information such as filenames, user inputs, or temporary results.
Declaring & Assigning Variables
To create a variable, you simply assign a value to a name. No special keyword is needed!
- Use
NAME="Coddy"(no spaces around=). - Values with spaces usually need quotes (single or double).
- Numbers don't strictly need quotes, but it's often good practice for consistency.