You will create a bash script that handles options and arguments.
You have completed the exercise “Skapa Bash-skript med options, command och arguments”.
You have read the course literature and acquired basic knowledge about bash. You’ve done the task “bash2”.
You will create your own
commands.bash script that receives options and arguments. The script can use built-in bash functions.
Use the guide if you get stuck.
Learn to use the manual
Create a bash script
script/commands.bashthat can receive options and arguments. If your script is called without options or arguments, the script should print that you can get help by using
Change permissions for the script by using the command
chmod 755 script/commands.bash
Your script should end with the correct exit value.
Use a main function to start the program.
Structure the code into different functions.
The following options should work:
|Option||What should happen|
||Print a help text on how to use the program.|
||Displays the current version of the program.|
- The following arguments should work:
|Argument||Vad skall hända|
||Print a calendar.|
||Print a greeting phrase to the current user.|
||Print the numbers between <min> and <max> using a forloop.|
||Print all numbers less than 42. The amount of numbers passed should not matter.|
||Print a sentence backwards (ecnetnes modnar).|
||Run all functions consecutively. The values you choose yourself. Please work on getting a nice presentation.|
commands.bash script by doing the following commands in the course directory in the terminal.
# Flytta till kurskatalogen $ dbwebb validate script
Correct any errors that pop up and publish again. When it looks green you are done.
- 2019-08-20: (A, lew) First edition.