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):

  1. Message if there were at least one argument passed to it as positional parameters
  2. If there was at least one positional parameter passed to it, prints to the standard output (screen/terminal):
    1. Number of arguments that were passed to it as positional parameters
    2. The first and third argument passed to it as one of the positional parameters
    3. 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)
  3. If there was at least one positional parameter passed to it,
    1. Store all the arguments/parameters that were passed to it in an array
    2. Prints to the standard output length of the array
    3. Length of the 3rd element of the array
    4. All the elements of the array in a single line

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!