Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Practicing Bash decision structure A telephone directory, called teledir.txt, maintains records in the form name: number where number is of the form pnn-nnn-nnnn Devise

image text in transcribed

Objective: Practicing Bash decision structure A telephone directory, called teledir.txt, maintains records in the form name: number where number is of the form pnn-nnn-nnnn Devise a shell script that accepts one or two arguments that could be: the name or number. If it exists in the directory, then the line should be displayed ii)both. The entry is displayed if it exists and is added if it doesn't exist in the le You can follow the steps below (not the only way) 1. Assign the pathname to the file teledir.txt to a variable, say, TELEDIR. For example, if it is in your home directory, you'll need to assign SHOME/teledir.txt to the variable TELEDIR Check that one or two arguments are supplied using $# and the case construct 2. esac a) If one or two arguments are supplied, do nothing b) otherwise, Indicate that the usage must be in the form scriptname [name number], then exit 3. Using the $# and the case esac construct, a) If one argument is supplied, If it starts with a digit, search it in the file. If it doesn't exist, echo that "Number doesn't exist" If it starts with a letter (lower or uppercase), search it in the file. If it doesn't exist, echo that "Name doesn't exist" b) If two arguments are supplied, set the search pattern to be "name: number", and search it in the file " If it is not found, echo "Adding entry", and append to the file/variable - Otherwise, echo that "Entry exists

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Why is succession planning important?

Answered: 1 week ago

Question

Derive expressions for the rates of forward and reverse reactions?

Answered: 1 week ago

Question

Write an expression for half-life and explain it with a diagram.

Answered: 1 week ago

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago