Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Copy files either to the screen or to another file (lastnameCP.c): Your second deliverable is another C program (call it lastnameCP) that is a

3. Copy files either to the screen or to another file (lastnameCP.c):

Your second deliverable is another C program (call it lastnameCP) that is a simplified/diffreent version of the linux "cp" command. Your program will only copy a file from one locatoin to aanother(ii.e., will not handle copying directories, copying links, recursively copying, etc).

The command does the following:

- Takes either one or two file names (source file sFile, and destination file dFile) as input

- Takes the following flag combinations:

-s: sends the content of the file to the screen

-f: if the dFile exists, its content is overwritten with content from y, otherwise the sFile content is copied to a new y.

-f -e: appends contents of sFile to the end of dFile

The commands below show the results given the following files:

file1 contains: "this is the content of file 1."

file2 contains: "this is the content of file 2."

- $lastnameCP -s file1

"this is the content of file 1." Will be displayed on the screen.

- $lastnameCP -f -e file1 file2

- file2 contains: this is the content of file 2. This is the content of file 1."

- $lastnameCP -f file1 file2

file2 contains: "This is the content of file 1."

- Other input combinations should give the user hint messages of how to use the command. for example:

- $lastnameCP -f file1

"Error: you need a source and a destination files with the -f flag(e.g. lastnameCP -f sFile dFile ...)"

- $lastnameCP -s

"Error: you need a source file with -s flag (e.g. lastnameCP -s sFile... )"

- $lastnameCP -f -e file1

"Error: you need a source and a destination files when using the -f -s flags (e.g. lastnameCP -f sFile dFile ...)"

***note***: Use system calls instead of library functions wherever possible.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

2) Find the global max and min of f(x) = 2 - x3 -2

Answered: 1 week ago