Question

In: Computer Science

If you have a script called testscr, that you execute with the following pipeline: echo two...

If you have a script called testscr, that you execute with the following pipeline:

echo two four six eight ten | testscr
and testscr contains the following lines of code:

# This is a read test
read parm1 parm2 parm3
echo :$parm1:$parm2:$parm3:

What gets printed?

Solutions

Expert Solution


PLEASE FIND THE ANSWER(S) and EXPLANATION BELOW.

We will get :two:four:six eight ten: as the output.

EXPLANATION:

In the command echo two four six eight ten | testscr , the pipe operator will pass the output of left side command to the right side command.

echo two four six eight ten has the output "two four six eight ten"

This will be passed as the input to the script testscr.

Hence,

  • param1 = two
  • param2 = four
  • param3 = six eight ten ( ALL THE REMAINING INPUT)

The line: read parm1 parm2 parm3 will read the data into respective params.

echo :$parm1:$parm2:$parm3: command line will print the output as

:two:four:six eight ten:


Related Solutions

For this part of the assignment I want you to execute the script CS50_hw_session04b. This will...
For this part of the assignment I want you to execute the script CS50_hw_session04b. This will create a directory called hw_session04 in your home directory. Change directories to hw_session04. - Execute file_1 in hw_session04 - Read file_2 in hw_session04 - Create the file dir_3/name with the output of the whoami command and the first secret code when you execute file_1. Save the output of executing file_1 exactly as shown. There should be two lines in dir_3/name. - Create the file...
Create a shell script called (Main.sh). The script must call the following scripts (FileS.sh), (Work.sh), (Ether.sh),...
Create a shell script called (Main.sh). The script must call the following scripts (FileS.sh), (Work.sh), (Ether.sh), (Arch.sh) and (Buzz.sh). The first script Main.sh must have two subroutines. The First Subroutine will display the following messages on the screen: 1-Display User login name, date and time. 2-Display System boot time. 3-Working path and Shell type 4-Display Home directory and number of files and directories in your Home. 5-Message describing briefly the requited tasks.
In C language, Write a program called minishell that creates two child processes: one to execute...
In C language, Write a program called minishell that creates two child processes: one to execute 'ls -al' and the other to execute ‘grep minishell.c’. After the forks, the original parent process waits for both child processes to finish before it terminates. The parent should print out the pid of each child after it finishes. The standard output of 'ls -al' process should be piped to the input to the 'grep minishell.c' process. Make sure you close the unnecessary open...
Use the following words to script that mirrors a conversation that you might have with a...
Use the following words to script that mirrors a conversation that you might have with a family member regarding annual property taxes paid on your house/property. a. Property Tax b. Percent of Appraised Value c. Mills (Millage Rate) d. Ad Valorem Tax e. Real Estate or Real Property
Examine the following shell script and describe its function line-by-line: #!/bin/bash echo -e "Which file would...
Examine the following shell script and describe its function line-by-line: #!/bin/bash echo -e "Which file would you like to copy> --> \c" echo -e "Which file would you like to copy? --> \c?" read FILENAME mkdir /stuff || echo "The /stuff directory could not be created." && echo "The /stuff directory could not be created." cp -f $FILENAME /stuff && echo "$FILENAME was successfully copied to /stuff"
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the...
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the exercises below. Increase N a number of times according to N = 4, 8, 16, 32, 64, 128, . . . (1) Determine for each N the (exact) error. (2) Determine for N ≥ 16 also the convergence ratio q(h/2). This script should be based on a function-file trap.m (trapezoidal integration) as follows: function [totarea] = trap(N) format long; a = 0; b =...
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt,...
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt, and then run the script. Explain your observations and how you can rectify the behavior.
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt,...
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt, and then run the script. Explain your observations and how you can rectify the behavior.
Write the following Python script: Write a function called linsolve() that will be useful in categorizing...
Write the following Python script: Write a function called linsolve() that will be useful in categorizing and solving linear algebra problems. The function will have up to three parameters: • A required 2D array representing the coefficient matrix of a linear algebra equation, • A required 1D or 2D array representing the right-side constants of a linear algebra equations, and • An optional parameter used to determine which condition number to use in determining the condition of the system. The...
Assume you have the following jobs to execute with one processor, with the jobs arriving in the order listed above.
i t(pi) 0 80 1 20 2 10 3 20 4 50 Assume you have the following jobs to execute with one processor, with the jobs arriving in the order listed above. Suppose a system uses FCFS scheduling. Create a Gantt chart illustrating the execution of these processes . b   What is the turnaround time for process p3? c.   What is the average wait time for the processes? Using the process load above, suppose a system uses SJN scheduling. d...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT