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...

Configure the enable secret on the router to be ciscopress. List the command sequence required to accomplish this task.

What will be an ideal response?

Computer Science & Information Technology

A flaw in software programming is a ________

A) hotfix B) virus C) bug D) Trojan horse

Computer Science & Information Technology

The ________ in a File Explorer window shows the current location in the folder structure

A) address bar B) Quick Access Toolbar C) library D) Live Preview

Computer Science & Information Technology

In client based virtualization the host OS sits on the Hypervisor

a. true b. false

Computer Science & Information Technology