Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Unix Assignment Question 1. List three or more benefits of getopt/getopts verses

ID: 3591890 • Letter: U

Question

Unix Assignment

Question 1. List three or more benefits of getopt/getopts verses traditional parsing?

Question 2. The following is true about file-redirection metacharacters: (Choose all that apply.)

a. The < directs the content of a file to the command.

b. The > directs the standard output of a command to a file.

c. The 2> directs standard input of a command to a file.

d. The &> directs only standard error of a command to a file.

e. The >> directs standard output of a command and overwrites the file.

Question 3. Explain how to prompt a user for information and then capture the input.

Question 4. Which positional variable calls the file name as an arugment?

a. $0

b. $X

c. $#

d. Y

e. $1

Explanation / Answer

1)Benifits of getopt/getopts over a manual loop:

1. handle the extraction of files which is similar to unix style i.e., -xvf filename
2. it always make sure, like the standard command, the options are parsed.
3. the error messages are localised in the language of user.

2) a and b are correct

The < directs the content of a file to the command

The > directs the standard output of a command to a file.

3) Using the read command we can prompt the user

example : lets consider a script test.sh

read -p "what is your name ? :" name

echo "Hi $name, how are you? lets be friends!!"

save the test.sh with execute permissions. i.e., chmod +x test.sh

Output :

what is your name : Aravind

Hi Aravind, how are you? lets be friends!!

4) $0  positional variable calls the file name as an arugment

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote