In this task you need to create some functions.
⚠️ Please, don't call your functions in./functions.sh
file. This would breake unit-tests. Create a new file and dosource ./functions.sh
there to test your functions.
Develop a pow()
function that takes two arguments (a, b)
and raises the first argument to the power of the second (a^b)
.
pow 2 3
-> 8
pow 2 5
-> 32
Develop the shortest()
function, which can take an unlimited number of arguments(strings) and output the shortest argument.
shortest "This" "is" "Bash" "Functions" "Task"
is
If there are more than two arguments, output each string on a new line. In an order they are passed to function.
shortest "Java" "Bash" "Python"
Java
Bash
Develop a print_log()
function that takes a string as an argument and outputs the same string with the date at the beginning.
In order for the automatic check to work, the string must be in this format: YEAR-MONTH-DAY HOUR:MINUTES
print_log "Hello World!"
-> [2022-05-10 13:04] Hello World!
print_log "Hello Bash!"
-> [2022-05-10 13:10] Hello Bash!