Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Background: Here's a small shell script that compares two files: #!/bin/sh # compare f1 f2 # script to compare and comment on differences between 2

Background: Here's a small shell script that compares two files:

 

#!/bin/sh

# compare f1 f2

# script to compare and comment on differences between 2 files echo comparing $1 with $2

if diff $1 $2; then

echo true

else

echo false

fi

If you store this script in a file called compare and make that file executable with chmod +x compare, you can run it with ./compare f1 f2 for any 2 files f1 and f2. (Try it with small files.) Note, in the script, $1 is a reference to the first command line argument, and $2 is a reference to the second. This is really bad language design, but it works, so we live with it.

a) Does the diff command return an idication of success or failure? If so, when does it indicate success and when does it indicate failure. The above script lets you test this empirically. (0.5 points)

b) Suggest a script that could be used in the test script in order to allow each test to be coded on one line, assuming that there were existing files holding the input, the expected output, and the expected error messages for each test, stored in the testfiles directory. (0.5 points)

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

Step: 3

blur-text-image

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

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago