0
0
Bash Scriptingscripting~15 mins

Style guide and conventions in Bash Scripting - Mini Project: Build & Apply

Choose your learning style9 modes available
Style Guide and Conventions in Bash Scripting
📖 Scenario: You are working as a junior system administrator. Your team wants all bash scripts to follow a clear style guide. This helps everyone read and maintain scripts easily.
🎯 Goal: You will create a simple bash script following good style and naming conventions. This includes using clear variable names, comments, indentation, and consistent formatting.
📋 What You'll Learn
Create variables with lowercase names and underscores
Add comments explaining the script
Use indentation for readability
Use double quotes around variables
Print a clear message as output
💡 Why This Matters
🌍 Real World
Following style guides in bash scripting helps teams maintain scripts that automate system tasks, backups, and monitoring.
💼 Career
System administrators and DevOps engineers write bash scripts daily. Clear style and conventions reduce errors and improve collaboration.
Progress0 / 4 steps
1
Create variables with clear names
Create two variables called user_name and user_age. Set user_name to "Alice" and user_age to 30.
Bash Scripting
Need a hint?

Use lowercase letters and underscores for variable names. Assign strings with quotes and numbers without quotes.

2
Add comments and use indentation
Add a comment above the variables explaining they store user info. Then add a comment below explaining the script prints a greeting. Use indentation for the print command in the next step.
Bash Scripting
Need a hint?

Start comments with # and keep them short and clear. Leave a blank line between sections for readability.

3
Use double quotes around variables in echo
Write an echo command that prints: Hello, Alice! You are 30 years old. Use the variables user_name and user_age inside double quotes. Indent the echo command with 4 spaces.
Bash Scripting
Need a hint?

Use double quotes around the whole string and $variable to insert values. Indent with spaces, not tabs.

4
Run the script and check output
Run the script and print the output. The output should exactly be: Hello, Alice! You are 30 years old.
Bash Scripting
Need a hint?

Run the script in your terminal or use bash script.sh if saved in a file.