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
Data transmission: Most digital communication data is transmitted in a serial form, that is, only one bit at a time. Transmission of data in serial form means each bit is tran

Question 1 Explain with an example the three kinds of relationships that are most important in object oriented modeling Question 2 Describe the Common Modeling techniques in

Question 1 Briefly explain the classification of the computers Question 2 What is arithmetic logic unit? How it is helpful in CPU Question 3 How do you install a new pri

These addressing modes are: With immediate addressing, no lookup of data is essentially required. The data is located in the operands of the instruction itself, not in a different

Input/Output Services:   Every operating system, large or small, provides input/output services for each device in the system. The operating system includes I/O device driver

QUESTION (a) You have been asked to design and implement a chat application. Which protocol would you used TCP or UDP? Justify your answer. (b) Explain why multithreading is

the chemical reactions in a battery produce ____________, each of which carries energy.

Technology Partnerships: Such agreements provide the consumer un-limited access to vendor's technology. Such contracts are typically multi-year in nature where the consumer pa

Source and Object Programs A set of instructions in a high-level language are called “Source program”. Since high-level languages are machine independent, it is required to fir

This is a C file. 1. The program starts by printing your name with an end sign ">". For example, "NAME >"; 2. Then, you can type in a string. If the string is not "vi xxx", you pri