Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROCEDURE Do the following exercises for practice. They are designed to help you become familiar with some of the common ways in which to use

PROCEDURE Do the following exercises for practice. They are designed to help you become familiar with some of the common ways in which to use the sed utility in UNIX. Submit only those screenshots of each exercise that have a (*) after it. 1. Copy the file /tmp/chin4 to your home directory. This will give you a text file to try out your sed commands. 2. In the following, use sed from the command line prompt. You do not have to alter the original file or create a new file in each case; just allow sed to send its output to the screen. Create sed commands to: a. Append ten caret symbols ^^^^^^^^^^ underneath line 1 of the file. (*) b. Append ten caret symbols and a blank line underneath line 1 of the file. c. Find all lines which contain it or It, and append Line contains it. underneath each one. (*) d. Change lines 4 to 6 of the file to the single line Lines 4 to 6 removed. e. Change any line that contains a colon to the line Colon found. (*) f. Change any line that contains a double-quote " to the line Double-quote found. g. Change any line that contains a single-quote ' to the line Single-quote found. h. Insert a line with your name in it before line 1 of the file. i. Insert the line Full stop approaching. before every line containing a period. (*) j. Delete lines 10 through to the end of the file. (*) k. Delete all lines that are empty or contain only whitespace. (*) l. Delete all lines containing a period. m. Delete all lines that do not contain a period. (*) n. Replace all occurrences of two spaces after the end of a sentence with just one space. (*) o. From lines 10 to the end of the file, replace every occurrence of e with E. p. Give your file a fake French accent by replacing all occurrences of th with z. (*) q. Replace every occurrence of . in the file with .... r. Indent by three spaces the lines beginning at the line that starts Chin and ending at the line that starts Fitzgerald. (*) 3. Working with sed on the command line can be tedious and frustrating. Try the following but, put the commands in a text file first. Recall that the method is to put the sed command(s) in the text file (e.g. sedfile) and then to issue the command sed f sedfile chin4, where chin4 is the file to edit. a. Do 2b, 2l, 2o, 2q using files instead of the command line. b. Give your file a bad accent again, this time changing the to da and The to Da. In your file of commands on the first line use a command for thethes, and on the next line use a command for the "The"s.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability & Statistics For Engineers & Scientists

Authors: Ronald E. Walpole, Raymond H. Myers, Sharon L. Myers, Keying

7th Edition

9789813131279, 130415294, 9813131276, 978-0130415295

Students also viewed these Databases questions