Question: Problem 2: Write a bash script that prints to the standard output (screen/terminal) (you may use echo command): Message if there were at least one
Problem 2:
Write a bash script that prints to the standard output (screen/terminal) (you may use echo command):
- Message if there were at least one argument passed to it as positional parameters
- If there was at least one positional parameter passed to it, prints to the standard output (screen/terminal):
- Number of arguments that were passed to it as positional parameters
- The first and third argument passed to it as one of the positional parameters
- The last arguments that was pass to it as the positional parameters or a message to the standard error that No arguments has been received, if it is a case (For this problem, you may find useful to use bash variable ${!name}, which means the value of the parameter whose name is $name. This works when $name is either a named parameter or a number (denoting a positional parameter). Another way would be to use bash variable BASH_ARGV or shift command)
- If there was at least one positional parameter passed to it,
- Store all the arguments/parameters that were passed to it in an array
- Prints to the standard output length of the array
- Length of the 3rd element of the array
- All the elements of the array in a single line
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
