Write a script named all that displays (sends to standard output) the name of the calling program, the number of positional parameters, and a list of positional parameters. Include the #! line (Sobell, page 297) and a comment (Sobell, page 298). Remember to make the file executable (Sobell, page 100). Test the script with 0, 1, and 5 positional parameters.

What will be an ideal response?

$ cat all
#!/bin/bash
#
# Program to display its name, the number of arguments it
# was called with, and a list of those arguments.
#
echo "This script was called as $0."
echo "This script was called with $# arguments."
echo "The arguments were: $*"
$ ./all
This script was called as ./all.
This script was called with 0 arguments.
The arguments were:
$ ./all one
This script was called as ./all.
This script was called with 1 arguments.
The arguments were: one
$ ./all 11 12 13 14 15
This script was called as ./all.
This script was called with 5 arguments.
The arguments were: 11 12 13 14 15

Computer Science & Information Technology

You might also like to view...

The need to improve coordination of strategic military forces prompted the development of the Internet as we know it today

Indicate whether the statement is true or false

Computer Science & Information Technology

A Web ____________________ is a program that runs on your computer to fetch and display Web pages.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology