Revision as of 09:08, 15 December 2003 editEloquence (talk | contribs)Extended confirmed users17,329 edits super-sed | Revision as of 16:30, 9 September 2008 edit WilyD (talk | contribs)Extended confirmed users32,255 edits →September 2008: Knock it off already | ||
Line 1: | Line 1: | ||
]]]]] | |||
'''Sed''' (which stands for '''S'''tream '''ED'''itor) is a simple but powerful computer program used to apply various pre-specified textual transformations to a sequential stream of text data. It reads input files line by line, edits each line according to rules specified in its simple language (the ''sed script''), and then outputs the line. While originally created as a ] utility by Lee E. McMahon of ] in ]/], sed is now available for virtually every operating system that supports a ]. | |||
== September 2008 == | |||
Sed is often thought of as a non-interactive ]. | |||
It differs from conventional text editors in that the processing of the two inputs is inverted. | |||
Instead of iterating once through a list of edit commands applying each one to the whole text file in memory, sed iterates once through the text file applying the whole list of edit commands to each line. | |||
Because only one line at a time is in memory, sed can process arbitrarily-large text files. | |||
] Welcome to Misplaced Pages. The <span class="plainlinks"></span> you made to ] has been reverted, as it appears to have removed content from the page without explanation. Use the ] for testing; if you believe the edit was constructive, ensure that you provide an informative ]. You may also wish to read the ]. Thank you. <!-- Template:uw-huggledelete1 --> ] (]) 02:58, 6 September 2008 (UTC) | |||
Sed's command set is modeled after the ] editor, and most commands work similarly in this inverted paradigm. For example, the command '''25d''' means ''if this is line 25, then delete (don't output) it'', rather than ''go to line 25 and delete it'' as it does in ed. The notable exception is the copy and move commands, which span a range of lines and thus don't have straight-forward equivalents in sed. Instead, sed introduces an extra | |||
buffer called the ''hold'' space, and additional commands to manipulate it. | |||
The ed command to copy line 25 to line 76 ('''25t76''') for example would be coded as two separate commands in sed ('''25h; 76g'''), to store the line in the hold space until the point at which it should be retrieved. | |||
] Welcome to Misplaced Pages. The <span class="plainlinks"></span> you made to ] has been reverted, as it appears to be unconstructive. Use the ] for testing; if you believe the edit was constructive, ensure that you provide an informative ]. You may also wish to read the ]. Thank you. <!-- Template:uw-huggle1 --> ]]] 16:08, 9 September 2008 (UTC) | |||
The following example shows a typical usage of sed: | |||
sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName | |||
] You currently appear to be engaged in an ]{{#if:|  according to the reverts you have made on ]}}. Note that the ] prohibits making more than three reversions on a single page within a 24 hour period. Additionally, users who perform a large number of reversions in content disputes may be blocked for edit warring, even if they do not technically violate the ]. If you continue, '''you may be ] from editing'''. Please do not repeatedly revert edits, but use the talk page to work towards wording and content that gains a ] among editors. If necessary, pursue ]. {{#if:|{{{2}}}|}}<!-- Template:uw-3rr --> ]<font color="FF8800">]</font> 16:30, 9 September 2008 (UTC) | |||
The ''s'' stands for substitute; the ''g'' stands for global. That means in the whole line. After the first slash is the ] 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 ] in a ]: | |||
generate_data | sed -e 's/x/y/' | |||
That is, generate the data, but 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 like | |||
sed -f subst.sed inputFileName > outputFileName | |||
Besides substitution, other forms of simple processing are possible. For example the following script deletes empty lines or lines that only contain spaces: | |||
sed -e '/^ *$/d' inputFileName | |||
This example used some of the following ]s: | |||
* ^ Matches the beginning of the line | |||
* $ Matches the end of the line | |||
* . Matches any single character | |||
* * Matches zero or more occurrences of the previous character | |||
* Matches any of the characters inside the | |||
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 ] command. Cousin to the later ], 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. | |||
Sed and AWK are often cited as the progenitors and inspiration for ]; in particular the s/// syntax from the example above is part of Perl's syntax. | |||
Sed's language does not have variables and only primitive ] and branching functionality; nevertheless, the language is ]. | |||
There is an extended version of sed called '''Super-sed''' that includes several new features such as in-place editing of files. | |||
===External links:=== | |||
* | |||
* | |||
* | |||
* | |||
* | |||
---- | |||
In ], '''Sed''' was a god of redemption. | |||
Alternative: Sedim |
Revision as of 16:30, 9 September 2008
September 2008
Welcome to Misplaced Pages. The recent edit you made to North America has been reverted, as it appears to have removed content from the page without explanation. Use the sandbox for testing; if you believe the edit was constructive, ensure that you provide an informative edit summary. You may also wish to read the introduction to editing. Thank you. Brougham96 (talk) 02:58, 6 September 2008 (UTC)
Welcome to Misplaced Pages. The recent edit you made to North America has been reverted, as it appears to be unconstructive. Use the sandbox for testing; if you believe the edit was constructive, ensure that you provide an informative edit summary. You may also wish to read the introduction to editing. Thank you. J.delanoyadds 16:08, 9 September 2008 (UTC)
You currently appear to be engaged in an edit war. Note that the three-revert rule prohibits making more than three reversions on a single page within a 24 hour period. Additionally, users who perform a large number of reversions in content disputes may be blocked for edit warring, even if they do not technically violate the three-revert rule. If you continue, you may be blocked from editing. Please do not repeatedly revert edits, but use the talk page to work towards wording and content that gains a consensus among editors. If necessary, pursue dispute resolution. WilyD 16:30, 9 September 2008 (UTC)