Function definition
📖 Scenario: You are creating a small bash script to greet users by name. This script will use a function to keep the greeting message reusable and neat.
🎯 Goal: Build a bash script that defines a function called greet which takes a name as input and prints a greeting message. Then call this function with a specific name.
📋 What You'll Learn
Create a function named
greetThe function should accept one argument (a name)
The function should print
Hello, <name>! where <name> is the argumentCall the
greet function with the name AlicePrint the greeting message to the terminal
💡 Why This Matters
🌍 Real World
Functions in bash scripts help automate repetitive tasks like sending messages, processing files, or managing system settings.
💼 Career
Knowing how to write and use functions in bash is essential for system administrators, DevOps engineers, and anyone automating tasks on Linux or Unix systems.
Progress0 / 4 steps