Introducing Regular Expressions by Michael Fitzgerald

Introducing Regular Expressions by Michael Fitzgerald

Author:Michael Fitzgerald [Michael Fitzgerald]
Language: eng
Format: epub, mobi, pdf
Tags: COMPUTERS / Programming / General
ISBN: 9781449338893
Publisher: O'Reilly Media
Published: 2012-07-09T16:00:00+00:00


Transforming Plain Text with sed

Let’s add some markup to the top of the text in rime.txt. We can do this with the insert command (i\). In the directory where the rime.txt file is located, enter the following at a shell prompt:

sed '1 i\ <!DOCTYPE html>\ <html lang="en">\ <head>\ <title>The Rime of the Ancyent Marinere (1798)</title>\ <meta charset="utf-8"/>\ </head>\ <body>\ q' rime.txt

After you press Enter or Return, your output should look like the following, with the tags at the top:

<!DOCTYPE html> <html lang="en"> <head> <title>The Rime of the Ancyent Marinere (1798)</title> <meta charset="utf-8"/> </head> <body> THE RIME OF THE ANCYENT MARINERE, IN SEVEN PARTS.

The command you just entered did not actually change the file—it only produced an output to your screen. I’ll show you how to write your changes to a file later.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.