Results for sed
On this page:
 

(1) (Stream EDitor) A Unix text editor that processes an entire file. It is the stream-oriented version of ed, an earlier text editor. Sed executes ed commands, but instead of editing one line at a time, sed applies the commands to the whole file.

(2) (SED) (Surface-Conduction Electron-Emitter Display) A thin CRT technology developed by Canon and Toshiba that is based on field emission technology (FED). Announced in 2002, SED TVs only a few centimeters thick are expected in 2008.

Using millions of low voltage surface-conduction electron-emitters (one for each pixel) on the cathode plate and regular CRT-like phosphors on the glass anode plate, the SED display uses a third of the power of plasma displays. SED prototypes at the 2006 Consumer Electronics Show in Las Vegas demonstrated remarkable clarity; however, LCD and plasma technologies are also improving. Due to legalities over sharing licensed technology relating to carbon nanotube emitters, Canon announced in early 2007 that it would buy out Toshiba's stake in the SED venture. See FED and plasma display.



 
 
is short for:

Meaning Category
Search Engine DatabaseInternet
Secure Encryption DeviceComputing->Security
Sedom, IsraelRegional->Airport Codes
Self Evaluation DocumentCommunity->Educational
Serious Emotional DisturbanceMedical->Physiology
Seriously Emotionally DisturbedCommunity->Law
Severe Emotional DisturbanceCommunity->Law
Severely Emotionally DisturbedCommunity->Educational
Shipper's Export DeclarationBusiness->International Business
Shipper's Export DocumentGovernmental->Transportation
Simple Encrypted DataComputing->Security
Site Equipment DemonstrationAcademic & Science->Electronics
Small End DiameterBusiness->Products
Smoke Emitting DiodeAcademic & Science->Electronics
Software Engineering DesignGovernmental->Military
Software Engineering DirectorateGovernmental->Military
Sozialistiche EinheitsparteiInternational->German
Space Exploration DayGovernmental->NASA
Special Enforcement DivisionCommunity->Law
Standard Erythema DoseMedical->Physiology
Stream Editor DiskComputing->Software
Surface-conduction Electron-emitter DisplayComputing->Hardware
Svetlana Electronic DevicesBusiness->Firms
The Sozialistischen Einheitspartei DeutschlandsGovernmental->Politics

Click here to submit an acronym.


 


sed (Stream EDitor) refers to a Unix utility for parsing text files and the programming language it uses to apply textual transformations to a sequential stream of data. It reads input files line by line, 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 on most operating systems.

Usage

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

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

The s stands for substitute; the g stands for global, which means that all matching occurrences in the line would be replaced. After the first slash is the regular expression to search for and after the second slash is the expression to replace it with. The substitute command (s///) is by far the most powerful and most commonly used sed command.

Under Unix, sed is often used as a filter in a pipeline:

generate_data | sed -e 's/x/y/g'

That is, generate the data, and then make the small change of replacing x with y.

Several substitutions or other commands can be put together in a file called, for example, subst.sed and then be applied using the -f option to read the commands from the file:

sed -f subst.sed inputFileName > outputFileName

Besides substitution, other forms of simple processing are possible. For example, the following deletes empty lines or lines that only contain spaces:

sed -e '/^ *$/d' inputFileName 

This example used some of the following regular expression metacharacters:

  • The caret (^) matches the beginning of the line.
  • The dollar sign ($) matches the end of the line.
  • A period (.) matches any single character.
  • The asterisk (*) matches zero or more occurrences of the previous character.
  • A bracketed expression delimited by [ and ] matches any of the characters inside the brackets.

Complex sed constructs are possible, to the extent that it can be conceived of as a highly specialised, albeit simple, programming language. Flow of control, for example, can be managed by use of a label (a colon followed by a string which is to be the label name) and the branch instruction b; an instruction b followed by a valid label name will move processing to the block following the label; if the label does not exist then the branch will end the script.

History

sed is one of the very early Unix commands that permitted 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 was probably the earliest Unix tool that really encouraged regular expressions to be used ubiquitously. In terms of speed of operation, sed is generally faster than Perl in execution and markedly faster than AWK.

sed and AWK are often cited as the progenitors and inspiration for Perl; in particular the s/// syntax from the example above is part of Perl's syntax.

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

GNU sed includes several new features such as in-place editing of files (i.e., replace the original file with the result of applying the sed program). In-place editing is often used instead of ed scripts: for example,

sed -i 's/abc/def/' file

can be used instead of

ed file
1,$ s/abc/def/
w
q

There is an extended version of sed called Super-sed (ssed) that includes regular expressions compatible with Perl.

Another version of sed is minised, originally reverse-engineered from the 4.1BSD sed by Eric S. Raymond and currently maintained by René Rebe. minised was used by the GNU project until the GNU project wrote a new version of sed based on the new GNU regular expression library. The current minised contains some extensions to BSD sed but is not as feature-rich as GNU sed. Its advantage is that it is very fast and uses little memory. It is used on embedded systems and is the version of sed provided with Minix.

Samples

This example will enable sed, which usually only works on one line, to remove newlines from sentences where the second sentence starts with one space.

Consider the following text:

This is my cat
 my cat's name is betty
This is my dog
 my dog's name is frank

The sed script below will turn it into:

This is my cat my cat's name is betty
This is my dog my dog's name is frank

Here's the script:

sed 'N;s/\n / /;P;D;'
  • (N) add the next line to the work buffer
  • (s) substitute
  • (/\n /) match: \n and one space
  • (/ /) replace with: one space
  • (P) print the top line of the work buffer
  • (D) delete the top line from the work buffer and run the script again

The Address Command (submatches)

More complex substitutions are possible using the "Address" command:

/pattern1/s/pattern2/replacement/flags   

Here, 'pattern1' is the address. The command following the address will only execute if the current line being processed matches the pattern (address) specified. This will replace pattern2 with replacement where pattern1 is matched. Likewise:

/pattern1/!s/pattern2/replacement/flags  
will replace pattern2 where pattern1 is *not* matched.

For example, if you have a file (text.txt) containing the following lines:

Hello world.
Hello world. I love lamp.

And you want to replace "world" with "mom", but only on those lines that contain the word "lamp", you can use:

sed -e '/lamp/s/world/mom/g' text.txt

will result in:

Hello world.
Hello mom. I love lamp.

You can negate this behavior with:

sed -e '/lamp/!s/world/mom/g' text.txt

which will result in the opposite:

Hello mom.
Hello world. I love lamp.

Exotic examples

Despite the limited possibilities of sed, there exist sed scripts for games as sokoban or arkanoid. Even some debuggers in sed have been made. [2]

Further reading

  • Dale Dougherty & Arnold Robbins (March 1997). sed & awk, 2nd Edition, O'Reilly. ISBN 1-56592-225-5. 
  • Arnold Robbins (June 2002). sed and awk Pocket Reference, 2nd Edition, O'Reilly and Associates. ISBN 0-596-00352-8. 
  • Peter Patsis (1998-12-30). UNIX AWK and SED Programmer's Interactive Workbook (UNIX Interactive Workbook). Prentice Hall. ISBN 0-13-082675-8. 
  • The sed FAQ
  • GNU sed manual

See also

External links



 
Best of the Web: sed

Some good "sed" pages on the web:


Egyptian Mythology
www.pantheon.org
 
 
 

Join the WikiAnswers Q&A community. Post a question or answer questions about "sed" at WikiAnswers.

 

Copyrights:

Computer Desktop Encyclopedia. THIS COPYRIGHTED DEFINITION IS FOR PERSONAL USE ONLY.
All other reproduction is strictly prohibited without permission from the publisher.
© 1981-2008 Computer Language Company Inc.  All rights reserved.  Read more
Abbreviations. STANDS4.com - The source for acronyms and abbreviations. Copyright ©2006 STANDS4 LLC. All rights reserved.  Read more
Wikipedia. This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Sed" Read more

Search for answers directly from your browser with the FREE Answers.com Toolbar!  
Click here to download now. 

Get Answers your way! Check out all our free tools and products.

On this page:   E-mail   print Print  Link  

 

Keep Reading

Mentioned In: