Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. First Script: Create a bash script combine (not combine. sh ) that takes 2 or more arguments, call them fl, f2, ..., fn For

image text in transcribed

1. First Script: Create a bash script combine (not combine. sh ) that takes 2 or more arguments, call them fl, f2, ..., fn For example, you could run combine by doing the following: . /combine f1 f2 f3 f4 f5 Script combine should work as follows: - All arguments are treated as filenames. - If fewer than two arguments are given, print a usage note to stderr and exit with a code of 1 Usage: combine outputfilename [inputfilename ] - If a file or directory f1 already exists, print Error: Output file should not exist on stderr and exit with a return code of 1 . Otherwise concatenate the contents of f2,, fn and put them in fl. You will want to handle errors with input files, but do not print any error mester from this (for example if some file does not exist or is a directory). Instead, these error messages should be written to f1. Exit with a return code of 0 after copying the input files. A simple example of running combine is: [localhost]\$ echo "making file 1" > file1 [localhost]\$ echo "and another one for file 2 " > file2 [localhost]\$ touch file3 [localhost]\$. /combine output filel file2 nonfile file3 [localhost]\$ cat output making file 1 and another one for file 2 cat: nonfile: No such file or directory Restriction: You may not use the file names /dev/stdout or / dev/stderr. These are not portable across * ix systems. Although they are found on most versions of Linux the problem can be solved without them. Hint: Put filenames in double-quotes in case they contain "funny characters" (such as spaces). Your script should work with any file names, no matter what they contain. Hint: cat, shift, $e,1t,a (you aren't required to use these, but may find them useful

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions