JDT

 

John Dixon
Technology
Limited

 
Google

Introduction to sed


sed (Stream EDitor) refers to a Unix utility which (a) parses text files and (b) implements a programming language that can apply textual transformations to such files.

It reads input files line by line (sequentially), applying the operation which has been specified via the command line (or a sed script), and then outputs the line.

It was developed from 1973 to 1974 as a Unix utility by Lee E. McMahon of Bell Labs, and is available today for most operating systems.

Usage

The following example shows a typical use of sed, where the -e option indicates that the sed expression follows:

     sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName

In many versions, the -e is not required to precede the expression. The s stands for substitute. The g stands for global, which means that all matching occurrences in the line would be replaced. The regular expression (i.e. pattern) to be searched is placed after the first delimiting symbol (slash here) and the replacement follows the second symbol. Slash is the conventional symbol. Any other could be used to make syntax more readable if it does not occur in the pattern or replacement.

History

sed is one of the very early Unix commands built for command line processing of data files. It evolved as the natural successor to the popular grep command. Cousin to the later AWK, sed allowed powerful and interesting data processing to be done by shell scripts.

sed and AWK are often cited as the progenitors and inspiration for Perl.

sed's language does not have variables and has only primitive GOTO and branching functionality; nevertheless, the language is Turing-complete.


Article source: http://en.wikipedia.org/wiki/Sed



Go back to Articles home page

Go back to Programming and Web Development Articles home page



Earnings Tracker is John Dixon Technology's FREE accounting / bookkeeping softwatre tool.

The software is written in PHP and MySQL and is available to use for FREE online, or as a FREE download.

Earnings Tracker, which is primarily aimed at very small businesses, for example, UK-based contractors and freelancers, lets you keep track of your company's revenue and spending, calculate corporation tax due, dividends that can be taken, dividend tax credits, and much more.

Earnings Tracker can also be used simply as a dividend, corporation tax, or VAT calculator.

free accounting software
 


JDT

© 2007-2009 - John Dixon Technology Ltd

Privacy Statement

Terms & Conditions