Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a script called grepsort that takes three argument as follows: $ grepsort argl arg2 arg3 argl, arg2, and arg3 are passed as arguments

image text in transcribed
1. Write a script called grepsort that takes three argument as follows: $ grepsort argl arg2 arg3 "argl", "arg2", and "arg3" are passed as arguments to the script. Example of the usage is S grepsort hello infile outfile This command will print the entries (lines) in file infile that contain the string hello and will append the output sorted to file outfile. Notice that the output is appended to arg3. Check for all possible errors (e.g. number of arguments, existence of the files, permission to read from arg2 and write to arg3, etc.) 2. Write a script called rmszfiles that deletes files containing more than a given number of bytes. As follows: $ rmszfiles sz f1 12 13 --- fn Argument sz is the size (number of bytes) and arguments fl through fn are the file names. The script should behave as follows: If no arguments are given i.e., sz is missing.) the script should write an error message to stderr and exit with a non-zero exit status. If at least the first argument (sz) is present, the script should process each of the file arguments f1 through fn in turn. For each file argument, If the file does not exist or is not a regular file, then ignore that argument and continue processing with the next file argument. Do not print any messages. If the file does exist and is a regular file (i.e., not a directory or some other kind of special file), then if it contains more than sz bytes it should be deleted. If there are no file arguments (i.e., only sz is present), the script should terminate without doing anything further. 1. Write a script called grepsort that takes three argument as follows: $ grepsort argl arg2 arg3 "argl", "arg2", and "arg3" are passed as arguments to the script. Example of the usage is S grepsort hello infile outfile This command will print the entries (lines) in file infile that contain the string hello and will append the output sorted to file outfile. Notice that the output is appended to arg3. Check for all possible errors (e.g. number of arguments, existence of the files, permission to read from arg2 and write to arg3, etc.) 2. Write a script called rmszfiles that deletes files containing more than a given number of bytes. As follows: $ rmszfiles sz f1 12 13 --- fn Argument sz is the size (number of bytes) and arguments fl through fn are the file names. The script should behave as follows: If no arguments are given i.e., sz is missing.) the script should write an error message to stderr and exit with a non-zero exit status. If at least the first argument (sz) is present, the script should process each of the file arguments f1 through fn in turn. For each file argument, If the file does not exist or is not a regular file, then ignore that argument and continue processing with the next file argument. Do not print any messages. If the file does exist and is a regular file (i.e., not a directory or some other kind of special file), then if it contains more than sz bytes it should be deleted. If there are no file arguments (i.e., only sz is present), the script should terminate without doing anything further

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

Students also viewed these Databases questions