Lines Matching full:command
4 @c (document the `;' command-separator)
9 @c @command for command
10 @c @samp for command fragments: @samp{cat -s}
56 @title @command{sed}, a stream editor
82 * sed Programs:: @command{sed} programs
85 * Other Resources:: Other resources for learning about @command{sed}
88 * Extended regexps:: @command{egrep}-style regular expressions
94 * Command and Option Index:: A menu with all @command{sed} commands and
95 command-line options.
101 * Execution Cycle:: How @command{sed} works
102 * Addresses:: Selecting lines with @command{sed}
105 * The "s" Command:: @command{sed}'s Swiss Army Knife
107 * Programming Commands:: Commands for @command{sed} gurus
154 @command{sed} is a stream editor.
159 permits scripted edits (such as @command{ed}),
160 @command{sed} works by making only one pass over the
162 But it is @command{sed}'s ability to filter text in a pipeline
170 Normally @command{sed} is invoked like this:
176 The full format for invoking @command{sed} is:
183 @command{sed} filters the contents of the standard input. The @var{script}
184 is actually the first non-option parameter, which @command{sed} specially
189 @command{sed} may be invoked with the following command-line options:
195 Print out the version of @command{sed} that is being run and a copyright notice,
201 Print a usage message briefly summarizing these command-line options
211 @cindex Disabling autoprint, from command line
212 By default, @command{sed} prints out the pattern space
216 and @command{sed} only produces output when explicitly told to
217 via the @code{p} command.
223 @cindex Script, from command line
278 Specify the default line-wrap length for the @code{l} command.
289 Most of the extensions accept @command{sed} programs that
291 of them (such as the behavior of the @command{N} command
305 @emph{and} a line feed character, and @command{sed} does not see the
306 ending CR. When this option is specified, @command{sed} will open
315 on the command line is a symbolic link, @command{sed} will
328 @command{egrep} accepts; they can be clearer because they
350 By default, @command{sed} will consider the files specified on the
351 command line as a single continuous long stream. This @value{SSED}
372 options are given on the command-line,
373 then the first non-option argument on the command line is
377 If any command-line parameters remain after processing the above,
386 @chapter @command{sed} Programs
388 @cindex @command{sed} program structure
390 A @command{sed} program consists of one or more @command{sed} commands,
395 This document will refer to ``the'' @command{sed} script;
399 Each @code{sed} command consists of an optional address or
400 address range, followed by a one-character command name
401 and any additional command-specific code.
404 * Execution Cycle:: How @command{sed} works
405 * Addresses:: Selecting lines with @command{sed}
408 * The "s" Command:: @command{sed}'s Swiss Army Knife
410 * Programming Commands:: Commands for @command{sed} gurus
417 @section How @command{sed} Works
423 @command{sed} maintains two data buffers: the active @emph{pattern} space,
426 @command{sed} operates by performing the following cycle on each
427 lines of input: first, @command{sed} reads one line from the input
429 Then commands are executed; each command can have an address associated
430 to it: addresses are a kind of condition code, and a command is only
431 executed if the condition is verified before the command is to be
437 if @command{sed} prints a line without the terminating newline, it will
441 identical to @command{cat}.} Then the next cycle starts for the next
451 @section Selecting lines with @command{sed}
452 @cindex Addresses, in @command{sed} scripts
456 Addresses in a @command{sed} script can be in any of the following forms:
462 (Note that @command{sed} counts lines continuously across all input files
497 passed to the @code{s} command). Note that modifiers to regular expressions
604 @code{0,/@var{regexp}/} so that @command{sed} will try to match
639 To know how to use @command{sed}, people should understand regular
658 of regular expression syntax as used in @command{sed}.
729 for example with an @code{s} command.
802 implementations of @command{sed}, rather than a tab character.
881 If you use @command{sed} at all, you will quite likely want to know
895 some implementations of @command{sed} (which are not @sc{posix}
901 Warning: if the first two characters of the @command{sed} script
910 This command only accepts a single address.
912 @findex q (quit) command
915 Exit @command{sed} without processing any more commands or input.
918 an exit code from the @command{sed} script is a @value{SSED} extension.
921 @findex d (delete) command
927 @findex p (print) command
930 This command is usually only used in conjunction with the @option{-n}
931 command-line option.
934 @findex n (next-line) command
939 If there is no more input then @command{sed} exits without processing
943 @findex @{@} command grouping
945 @cindex Command groups
953 @node The "s" Command
954 @section The @code{s} Command
956 The syntax of the @code{s} (as in substitute) command is
959 character within any given @code{s} command. The @code{/}
964 The @code{s} command is probably the most important in @command{sed}
966 the @code{s} command attempts to match the pattern
1011 @findex s command, option flags
1013 The @code{s} command can be followed by zero or more of the
1027 @cindex @acronym{GNU} extensions, @code{g} and @var{number} modifier interaction in @code{s} command
1028 @cindex Mixing @code{g} and @var{number} modifiers in the @code{s} command
1032 across @command{sed} implementations.
1049 while in general flags for the @code{s} command show their
1069 This command allows one to pipe input from a shell command
1070 into pattern space. If a substitution was made, the command
1073 results are undefined if the command to be executed contains
1084 extension which makes @command{sed} match @var{regexp} in a
1138 section, some very small yet useful @command{sed} scripts can be built with
1144 any other single character within any given @code{y} command.)
1146 @findex y (transliterate) command
1161 As a @acronym{GNU} extension, this command accepts two addresses.
1163 @findex a (append text lines) command
1166 Queue the lines of text which follow this command
1185 As a @acronym{GNU} extension, this command accepts two addresses.
1187 @findex i (insert text lines) command
1190 Immediately output the lines of text which follow this command
1196 @findex c (change to text lines) command
1199 and output the lines of text which follow this command
1204 A new cycle is started after this command is done,
1209 As a @acronym{GNU} extension, this command accepts two addresses.
1211 @findex = (print line number) command
1217 @findex l (list unambiguously) command
1230 the default as specified on the command line is used. The @var{n}
1235 As a @acronym{GNU} extension, this command accepts two addresses.
1237 @findex r (read file) command
1251 @findex w (write file) command
1269 @findex D (delete first line) command
1277 @findex N (append Next line) command
1282 If there is no more input then @command{sed} exits without processing
1286 @findex P (print first line) command
1291 @findex h (hold) command
1298 @findex H (append Hold) command
1305 @findex g (get) command
1312 @findex G (appending Get) command
1319 @findex x (eXchange) command
1328 @section Commands for @command{sed} gurus
1331 probably better off programming in something like @command{awk}
1333 with @command{sed}, and these commands can enable one to write
1341 @findex : (label) command
1347 @findex b (branch) command
1354 @findex t (test and branch if successful) command
1370 quite often, yet are unsupported by standard @command{sed}s.
1373 @item e [@var{command}]
1374 @findex e (evaluate) command
1379 This command allows one to pipe input from a shell command
1380 into pattern space. Without parameters, the @code{e} command
1381 executes the command that is found in pattern space and
1385 If a parameter is specified, instead, the @code{e} command
1386 interprets it as a command and sends its output to the output stream
1387 (like @code{r} does). The command can run across multiple
1390 In both cases, the results are undefined if the command to be
1394 @findex L (fLow paragraphs) command
1398 @cindex @value{SSEDEXT}, @code{L} command
1402 on the command line is used. This command is considered a failed
1417 the default as specified on the command line is used.
1421 This command only accepts a single address.
1423 @findex Q (silent Quit) command
1427 This command is the same as @code{q}, but will not print the
1431 This command can be useful because the only alternative ways
1446 @findex R (read line) command
1449 @cindex @value{SSEDEXT}, @code{R} command
1457 As with the @code{r} command, the special value @file{/dev/stdin}
1462 @findex T (test and branch if failed) command
1472 @findex v (version) command
1475 This command does nothing, but makes @command{sed} fail if
1477 versions of @command{sed} do not implement it. In addition, you
1478 can specify the version of @command{sed} that your script
1480 because that is the first version that implemented this command.
1482 This command enables all @value{SSEDEXT} even if
1486 @findex W (write first line) command
1490 the first newline. Everything said under the @code{w} command about
1494 @findex z (Zap) command
1497 This command empties the content of pattern space. It is
1502 way to clear @command{sed}'s buffers in the middle of the
1511 @samp{\^}, which tell @command{sed} not to interpret the circumflex
1523 that ordinarily are taken literally, and that @command{sed} replaces
1527 in a @command{sed} script but when a script is being prepared in the
1614 substitution using the @code{s///g} command and option, at
1624 Here are some @command{sed} scripts to guide you in the art of mastering
1625 @command{sed}.
1693 in @command{sed}. This is indeed possible,@footnote{@command{sed} guru Greg
1694 Ubben wrote an implementation of the @command{dc} @sc{rpn} calculator!
1746 This is a pretty strange use of @command{sed}. We transform text, and
1748 Don't worry, even worse hacks are done when using @command{sed}; I have
1749 seen a script converting the output of @command{date} into a @command{bc}
1752 The main body of this is the @command{sed} script, which remaps the name
1856 @section Print @command{bash} Environment
1859 from the output of the @command{set} Bourne-shell command.
1902 Note the @code{tx} command before the definition of the label.
1904 the @code{t} command.
1907 is reversing the output of @command{banner}.@footnote{This requires
1947 is a @command{tac} workalike.
1949 Note that on implementations other than @acronym{GNU} @command{sed}
1977 exactly like @acronym{GNU} @command{cat} does.
1995 It uses @command{sed} to print the line number, then groups lines two
2003 (using a @code{y} command). The line number for the next line
2055 not commented to show how important it is to comment @command{sed}
2092 This script shows another way to do arithmetic with @command{sed}.
2098 implemented with @command{sed}. @samp{a}s are units, @samp{b}s are
2169 It is interesting that real @command{wc} programs have optimized
2176 of commenting @command{sed} scripts.
2224 No strange things are done now, because @command{sed} gives us
2237 This script is probably the simplest useful @command{sed} script.
2239 lines is right before the @code{q} command.
2255 This script is similar to the @command{tac} script in that it keeps the
2270 by adding a line and deleting the oldest (the substitution command
2271 on the second line works like a @code{D} command but does not
2275 efficient and complex @command{sed} scripts, because commands like
2280 and @code{D} commands, here is an implementation of @command{tail}
2324 # the n command.
2329 # If the @code{N} command had added the last line, print and exit
2340 This technique is often used in advanced @command{sed} scripts.
2468 @code{b}, without relying on @command{sed} to restart the
2509 For those who want to write portable @command{sed} scripts,
2513 The @sc{posix} standard specifies that conforming @command{sed}
2555 as empty in the second half of an @code{s} command.
2599 @chapter Other Resources for Learning About @command{sed}
2601 @cindex Additional reading about @command{sed}
2602 In addition to several books that have been written about @command{sed}
2604 shell programming), one can find out more about @command{sed}
2614 which include @command{sed} tutorials and other @command{sed}-related goodies.
2640 cases for @command{sed} is quite simple.
2643 test, and the specific invocation of @command{sed} that causes the problem.
2645 not involve something as far removed from @command{sed} as ``try to configure
2652 @item @code{N} command on the last line
2653 @cindex Portability, @code{N} command on the last line
2654 @cindex Non-bugs, @code{N} command on the last line
2656 Most versions of @command{sed} exit without printing anything when
2657 the @command{N} command is issued on the last line of a file.
2659 the @command{-n} command switch has been specified. This choice is
2682 @cindex @code{POSIXLY_CORRECT} behavior, @code{N} command
2690 @command{sed} uses the @sc{posix} basic regular expression syntax. According to
2692 this syntax; notable in the case of @command{sed} are @code{\|},
2697 expressions, @command{sed} interprets these escape sequences as special
2702 @command{sed}s. Some @command{sed} programs have been written with the
2706 of @command{sed}, like
2710 @acronym{GNU} @command{sed}.
2714 @command{sed} 4.0.x, newer versions interpret this as removing the
2717 @command{sed}s, for example, required that the regex matcher parsed
2723 In addition, this version of @command{sed} supports several escape characters
2727 with scripts written for other @command{sed}s.
2748 reason, @command{sed} does not let you use @option{-i} on a writeable file
2797 command (for `zap') as an extension.
2887 You can often improve performance by avoiding that @command{sed} wastes
2946 is complicated. Outside a character class, @command{sed} reads it
2956 subpatterns, @command{sed} re-reads up to three octal digits following
2980 on the RHS of the `s' command.
3506 /* first command */ not comment /* second comment */
3638 RHS of the `s' command.
3875 matching proceeds from left to right, @command{sed} will look for
4036 appears. Obviously, @command{sed} cannot support the interpolation of
4101 exception of the @command{sed} commands and command-line options.
4106 @node Command and Option Index
4107 @unnumbered Command and Option Index
4109 This is an alphabetical list of all @command{sed} commands and command-line