Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ex. 1 - A basic shell script for searching tar files (8 Points) In class we explored the tar command that can be used to

image text in transcribedimage text in transcribed

Ex. 1 - A basic shell script for searching tar files (8 Points) In class we explored the tar command that can be used to archive files and entire directory structures. Sometimes we would want to check the contents of a tar file without extracting it back, such as to check if a particular filename is present in a given tar file. Programmers often keep such handy set of commands written together in the form of a shell script that can be used repeatedly. For this task, you will create a shell script named tarzan.sh which accepts 2 arguments - the name of a file, followed by a tar file's name. The tar file name maybe passed on using absolute path or relative path. The objective is to inform the user if a particular file is present in a tar file or not, without extracting it. The tar command provides you with an option to list all the contents in the tar file without extracting it. Use the man command to explore the tar command and find this option. Below is an example (valid) usage. $ ./tarzan.sh sort.c /archives/2017/gamingProject.tar 2 Points for writing code with proper (readability) indentation and writing necessary comments (required to un- derstand the logic, etc.) in the code. 1. Use vi to create your script in mimi.cs.mcgill.ca. 2.Ensure that your script can be executed using bash shell. 3.(2 Points) If the script is not passed two arguments to it, you must throw an error/usage message, such as the following example. $ ./tarzan.sh sort.c Usage ./tarzan.sh filename tarfile 4.(1 Point) If the tar file cannot be found, the script should throw an error message. $ ./tarzan.sh sort.c /archives/2017/gaming Project.tar Error cannot find tar file /archives/2017/gaming Project.tar 5.(1 Point) If the tar file is found, but the filename that is searched is not present in it, the script should display this fact. $ ./tarzan.sh sort.c /archives/2017/gaming Project.tar sort.c does not exist in /archives/2017/gaming Project.tar 6.(2 Points) If the script is able to locate the filename in the tar file, it should display the found message. $ ./tarzan.sh sort.c /archives/2017/gaming Project.tar sort.c exists in /archives/2017/gamingProject.tar

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

Are my points each supported by at least two subpoints?

Answered: 1 week ago