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
Pebble Merchant Problem Description There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides.

write a program to solve a 10x10 maze. prompt the user for an input text file containing ten rows(ten characters on each row). Use following characters in the input file: * startin

For the connections that request a static amount of bandwidth that is continuously available during the connection lifetime. Is intended to support real time applications requiring

StatefulServer, maintains some information between requests. Requires smaller messages, since some information is kept between contacts, example: FTP, telnet. Stateless Server req

The microprocessor is at times referred to as the ''brain'' of the personal computer, and is responsible for the processing of the instructions which creates computer software. It

QUESTION (i) Define each of the following terms: a) Interlibrary lending b) Manuscript c) Papyrus d) Community profile e) Mauritiana (ii) Explain with example

Different kinds of registers are general between most microprocessor designs. These are: Program Counter (PC) This register is utilized to hold the memory address of the next instr

What îs exactly data type and Database Assignment Help  ? We have can take several points of view, A data type îs set of values — char typically has 256 distinct values, into has

can u write my assignment for me

Memory hierarchy: There is another type of high speed memory, known as Cache memory, which is used to increase the speed of processing by making current programs and data avai