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
StatefulServer, maintains some information between requests. Requires smaller messages, since some information is kept between contacts, example: FTP, telnet. Stateless Server req

Ask quwhat is binary estion #Minimum 100 words accepted#

Function: The purpose of a function is to take in a number of values or arguments, do some calculations with those arguments and then return a single result.  Each language has d

Question 1 Explain the importance of graphics in multimedia. What are few of the tips to keep in mind while using graphics for the web? Question 2 Write a long note on co

Question 1 Write short notes on                           (a) Office Automatics System                           (b) Transaction Processing System Question 2 What is a too

I have an assignment i need it to get it done How much would I be charged for that?

Two-tiered architecture: This approach basically introduced a database server to replace the file server. The emergence of relational database management systems and graphica

You can also allocate a single value to several variables at the same time. For instance: X=y=z =1 Now, an integer object is generated with the value 1, and all three variables are

I n t e rnal Structure of Agents We have looked at agents in terms of their external influences and behaviors: they take input from the environment and perform rational act

QUESTION (a) Can SSL be used to encrypt email data? Justify your answer (b) What are the three basic security provided by SSL? (c) State the port number used by applicati