0
0
Bash Scriptingscripting~15 mins

Documentation with comments in Bash Scripting - Mini Project: Build & Apply

Choose your learning style9 modes available
Documenting a Bash Script with Comments
📖 Scenario: You are creating a simple Bash script to greet users and show the current date. To make your script easy to understand and maintain, you will add comments explaining each part.
🎯 Goal: Build a Bash script that prints a greeting and the current date, with clear comments documenting each step.
📋 What You'll Learn
Create a Bash script with variables and commands
Add comments explaining the purpose of variables and commands
Print output to the terminal
💡 Why This Matters
🌍 Real World
Writing clear comments in scripts helps others and your future self understand what the script does, making maintenance easier.
💼 Career
Clear documentation is a key skill for system administrators, DevOps engineers, and anyone writing automation scripts.
Progress0 / 4 steps
1
Create a Bash script with a greeting variable
Create a Bash script and define a variable called greeting with the value "Hello, welcome to the script!".
Bash Scripting
Need a hint?

Use greeting="Hello, welcome to the script!" to create the variable.

2
Add a comment explaining the greeting variable
Add a comment above the greeting variable that says # This variable stores the welcome message.
Bash Scripting
Need a hint?

Start the comment line with # followed by the explanation.

3
Add a command to print the greeting with a comment
Add a comment # Print the greeting message and then write the command echo "$greeting" to print the greeting.
Bash Scripting
Need a hint?

Use echo "$greeting" to display the message.

4
Add a comment and command to show the current date
Add a comment # Show the current date and time and then write the command date to display the current date and time.
Bash Scripting
Need a hint?

Use the date command to display the current date and time.