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

Design a file copying program named FileCopy using ordinary pipes. This program

ID: 3768472 • Letter: D

Question

Design a file copying program named FileCopy using ordinary pipes. This program will be passed two parameters: the first is the name of the file to be copied and the second is the copied file. The program will then create an odinary pipe and write the contents of the file to be copied to the pipe. The child process will read the file from the pipe and write it to the destination file. For example if we invoke the program as follows:
FileCopy input.txt copy.txt
and the file input.txt will be written to the pipe. The child process will read the contents of this file and write it to the destination file copy.txt. You may write this program using UNIX pipes.

Explanation / Answer

Put the below code in your favourite text editor and save it with executable permissings:

#!/bin/tcsh
cp $1 $2

The above code uses CP shell function to copy file to file; $1 and $2 are used to access the parameter 1 and 2.

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