Unix Shell, Basic Computer Science

Write a shell script, change-lines, which will substitute a string for a replacement string for each occurance of the string in files specified.
The original file will be saved, with the same filename with the .keep extension unless the -n option is present.

You may use a temporary file for this script.

Remember the search string and or the replacement string can have special characters in them, so you must use proper quoting techniques.

The script will use following options:


the option -s "string" for the search strings
the option -r "string" for the replacement string
the -n option to prevent a backup file from being created
the -h option to print a usage statement and exit
The script will exit with an error status and print an error message:
if the -s option is not present.
if the -r option is not present.
if the string is not specified with the -s option
if the string is not specified with the -r option
if there are any other options specified
if there are no input files specified
if the input file cannot be read by the current process
if the input file cannot be written by the current process
if you cannot create the backup file.
Here is the usage statement for the script:
change-lines [-n] -s search string -r replace string files ...
-n do not backup the original file
-s search string the search for this string
-r replace string replace the search string with this string
-h print this message
Posted Date: 11/10/2012 9:10:45 PM | Location : United States







Related Discussions:- Unix Shell, Assignment Help, Ask Question on Unix Shell, Get Answer, Expert's Help, Unix Shell Discussions

Write discussion on Unix Shell
Your posts are moderated
Related Questions
QUESTION Your Library is currently offering access to the Internet for its subscribers on a fee paying basis. Subscribers should make a booking for each slot of one hour in adv

They are used to act upon logic operations on the operators. AND OR, NEG NOT TEST XOR AND INSTRUCTION Function: It acts upon the conjunction of the operators bit by bit. Syntax: A

Question 1 What do you mean by semantic networks? Explain inheritance in semantic networks Question 2 Explain Partitioned semantic networks with an example Question

Keyboards, microphones, and mice have generally been used as the standard input devices for most computer systems. The popularity of video and computer games has led to the introdu

Problem 1 Perform the following conversion a. (ABE) 16 =() 2 b. (101011) 2 =() 10 2 Explain how full adder adds three bits 3 Explain digital multiplexers

Question 1 Explain the importance of edge loops and anatomical body functions in animation Question 2 What are the three sets of curves for the hair system? Questio

what is input and output device? explain meaning of input and output devices

An array A is said to be special if all its elements are same. Given an array, your task is to convert the array to special array by performing some operations. The allowed operati

7. Name and explain the action in Conceptual Dependency which refers to a transfer of possession.

two characteristics og CISC architecture?