In Bash, you can pass information to a function when you call it. These inputs are called parameters, and the function can access them using $1, $2, and so on. Here’s an example:
greet_user() {
echo “Hello, $1! You are $2 years old.”
}
greet_user “Alice” 25
When you run this, the function replaces $1 with “Alice” and $2 with 25, then prints:
Hello, Alice! You are 25 years old.
You can also use $# to see how many parameters were passed and $@ to get all parameters.