0
0
Bash Scriptingscripting~15 mins

Running scripts in Bash Scripting - Mini Project: Build & Apply

Choose your learning style9 modes available
Running Bash Scripts
📖 Scenario: You want to automate a simple task on your computer using a Bash script. This script will greet you and show the current date and time.
🎯 Goal: Create a Bash script file, make it executable, and run it to see the greeting and current date and time.
📋 What You'll Learn
Create a Bash script file named greet.sh.
Write a script that prints a greeting message and the current date and time.
Make the script executable using the correct command.
Run the script and display its output.
💡 Why This Matters
🌍 Real World
Running scripts is a basic way to automate tasks on your computer, like backups, reminders, or system checks.
💼 Career
Many IT and developer jobs require writing and running scripts to save time and reduce errors.
Progress0 / 4 steps
1
Create the Bash script file
Create a file named greet.sh and add the first line #!/bin/bash to specify the script interpreter.
Bash Scripting
Need a hint?

The first line of a Bash script should be #!/bin/bash to tell the system to use Bash to run it.

2
Add greeting and date commands
Add two lines to greet.sh: one to print Hello, welcome! using echo, and one to print the current date and time using the date command.
Bash Scripting
Need a hint?

Use echo "Hello, welcome!" to print the greeting and date to show the current date and time.

3
Make the script executable
Use the command chmod +x greet.sh to make the script file executable.
Bash Scripting
Need a hint?

Use chmod +x greet.sh in the terminal to allow running the script.

4
Run the script and display output
Run the script by typing ./greet.sh in the terminal and print the output.
Bash Scripting
Need a hint?

Run ./greet.sh in the terminal. You should see the greeting and the current date and time.