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 1 What is IT auditing? Discuss the three phases involved in the IT auditing Question 2 List and explain the two types of load balancing methods Question 3

History of E-mail: Internet based E-mail system was designed by a Computer engineer - Ray Tomlinson in late 1971 while working with ARPANET. Tomlinson used a file transfer pro

suggest 5 ways by which new products and services can be developed using management information system

(iv) Suppose that the TCP entity receives a 1.5 megabyte file from the application layer and that the IP layer is willing to carry blocks of maximum size 1500 bytes. Calculate the

online project on hrm i.e index page

Assembly language : Assembly language is a low level programming language similar to machine language, but far easier to write and understand because machine language binary in


Binary Codes: We have seen earlier that digital computers use signals that have two distinct values and there exists a direct analogy between binary signals and binary digits.