Hands-on task
This task is step 4 of the course “Your first bash script”
Script arguments: $1 and $#
Write the script /root/greet.sh. It takes a name as its first argument and prints two lines: a greeting and how many arguments it was given in total.
$ bash greet.sh Alice
Hello, Alice!
Arguments: 1
$ bash greet.sh Bob x y
Hello, Bob!
Arguments: 3
Don't write the name into the script — it must come from the argument, so the script works with any name, not just the ones in the example.
What you'll practise:
- bash scripts
- positional arguments
- $1
- $#