SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from Old RedHat 5.X sed-3.02-1.i386.rpm

SED

Section: User Commands (1)
Updated: 1998-05-07
Index 

NAME

sed - a Stream EDitor 

SYNOPSIS

sed [-n] [-V] [--quiet] [--silent] [--version] [--help]    [-e script] [--expression=script]    [-f script-file] [--file=script-file]    [script-if-no-other-script]    [file...]
 

DESCRIPTION

Sed is a stream editor.A stream editor is used to perform basic texttransformations on an input stream(a file or input from a pipeline).While in some ways similar to an editor whichpermits scripted edits (such as ed),sed works by making only one pass over theinput(s), and is consequently more efficient.But it is sed's ability to filter text in a pipelinewhich particularly distinguishes it from other types ofeditors.

 

OPTIONS

Sed may be invoked with the following command-line options:
-V
--version
Print out the version of sed that is being run and a copyright notice,then exit.
-h
--help
Print a usage message briefly summarizing these command-line optionsand the bug-reporting address,then exit.
-n
--quiet
--silent
By default, sed will print out the pattern spaceat the end of each cycle through the script.These options disable this automatic printing,and sed will only produce output when explicitly told tovia thepcommand.
-e script
--expression=script
Add the commands inscriptto the set of commands to be run while processing the input.
-f script-file
--file=script-file
Add the commands contained in the filescript-fileto the set of commands to be run while processing the input.

If no-e,-f,--expression,or--fileoptions are given on the command-line,then the first non-option argument on the command line istaken to be thescriptto be executed.

If any command-line parameters remain after processing the above,these parameters are interpreted as the names of input files tobe processed.A file name of-refers to the standard input stream.The standard input will processed if no file names are specified.

 

Command Synopsis

This is just a brief synopsis of sed commands to serve asa reminder to those who already know sed;other documentation (such as the texinfo document)must be consulted for fuller descriptions. 

Zero-address ``commands''

label
Label forbandtcommands.
#comment
The comment extends until the next newline (or the end of a-escript fragment).
}
The closing bracket of a { } block.
 

Zero- or One- address commands

=
Print the current line number.
a \
text
Appendtext,which has each embedded newline preceeded by a backslash.
i \
text
Inserttext,which has each embedded newline preceeded by a backslash.
q
Immediately quit the sed script without processingany more input,except that if auto-print is not diabledthe current pattern space will be printed.
filename
Append text read fromfilename.
 

Commands which accept address ranges

{
Begin a block of commands (end with a }).
label
Branch tolabel;iflabelis omitted, branch to end of script.
label
If a s/// has done a successful substitution since thelast input line was read and since the last t command,then branch tolabel;iflabelis omitted, branch to end of script.
c \
text
Replace the selected lines withtext,which has each embedded newline preceeded by a backslash.
d
Delete pattern space.Start next cycle.
D
Delete up to the first embedded newline in the pattern space.Start next cycle, but skip reading from the inputif there is still data in the pattern space.
h H
Copy/append pattern space to hold space.
g G
Copy/append hold space to pattern space.
x
Exchange the contents of the hold and pattern spaces.
l
List out the current line in a ``visually unambiguous'' form.
n N
Read/append the next line of input into the pattern space.
p
Print the current pattern space.
P
Print up to the first embedded newline of the current pattern space.
s/regexp/replacement/
Attempt to matchregexpagainst the pattern space.If successful, replace that portion matchedwithreplacement.Thereplacementmay contain the special character&to refer to that portion of the pattern space which matched,and the special escapes \1 through \9 to refer to thecorresponding matching sub-expressions in theregexp.
w
filenameWrite the current pattern space tofilename.
y/source/dest/
Transliterate the characters in the pattern space which appear insourceto the corresponding character indest.
 

Addresses

Sed commands can be given with no addresses, in whichcase the command will be executed for all input lines;with one address, in which case the command will only be executedfor input lines which match that address; or with twoaddresses, in which case the command will be executedfor all input lines which match the inclusive range oflines starting from the first address and continuing tothe second address.Three things to note about address ranges:the syntax isaddr1,addr2(i.e., the addresses are separated by a comma);the line whichaddr1matched will always be accepted,even ifaddr2selects an earlier line;and ifaddr2is aregexp,it will not be tested against the line thataddr1matched.

After the address (or address-range),and before the command, a!may be inserted,which specifies that the command shall only beexecuted if the address (or address-range) doesnotmatch.

The following address types are supported:

number
Match only the specified linenumber.
first~step
Match everystep'thline starting with linefirst.For example, ``sed -n 1~2p'' will print all the odd-numbered lines inthe input stream, and the address 2~5 will match every fifth line,starting with the second.(This is a GNU extension.)
$
Match the last line.
/regexp/
Match lines matching the regular expressionregexp.
\cregexpc
Match lines matching the regular expressionregexp.Thecmay be any character.
 

Regular expressions

POSIX.2 BREsshouldbe supported, but they aren't completely yet.The\nsequence in a regular expression matches the newline character.There are also some GNU extensions.[XXX FIXME: more needs to be said.At the very least, a reference to another document whichdescribes what is supported should be given.] 

Miscellaneous notes

This version of sed supports a\<newline>sequence inall regular expressions, thereplacementpart of a substitute (s) command, and in thesourceanddestparts of a transliterate (y) command.The \ is stripped, and the newline is kept. 

SEE ALSO

awk(1),ed(1),expr(1),emacs(1),perl(1),tr(1),vi(1),regex(5)[well, oneoughtto be written... XXX],sed.info,any of various books on sed,the sed FAQ (http://www.wollery.demon.co.uk/sedtut10.txt,http://www.ptug.org/sed/sedfaq.htm). 

BUGS

E-mail bug reports tobug-gnu-utilsAATTgnu.org.Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
Command Synopsis
Zero-address ``commands''
Zero- or One- address commands
Commands which accept address ranges
Addresses
Regular expressions
Miscellaneous notes
SEE ALSO
BUGS

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector