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 common read command options and explain t

ID: 3591891 • Letter: U

Question

Unix Assignment

Question 1. List three common read command options and explain their function.

Question 2. How can data from STDIN be sent to both a file and STDOUT?

Read the following shell script and answer the questions:

$cat script1

#!/bin/bash

exec 3<$1

exec 4<$2

exec 5>$3

while read line <&3

do

      echo “$line” >&5

done

while read line <&4

do

      echo “$line” >&5

done

Question 3. The script requires 3 filenames as arguments, e.g., ./script1 file1 file2 file3. Which files are input files and which are output files?

Question 4. Inside the while-loop, why does variable “$line” have to be enclosed by double quotes?

Explanation / Answer

1)

In UNIX We can use following option with read command:

1) -p It help to read to read input from the output of a process run bny KORN Shell

2) -r It tell the read command to treat a (backslash) character as part of the

input line, not as a control character.

3) -s To saves the input as a command in the Korn Shell history file.

3)

file file1 and file2 are input fie and file3 is an output file.

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