1 This is ../../doc/sed.info, produced by makeinfo version 4.5 from
4 INFO-DIR-SECTION Text creation and manipulation
6 * sed: (sed). Stream EDitor.
10 This file documents version 4.1.5 of GNU `sed', a stream editor.
12 Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004 Free Software
15 This document is released under the terms of the GNU Free
16 Documentation License as published by the Free Software Foundation;
17 either version 1.1, or (at your option) any later version.
19 You should have received a copy of the GNU Free Documentation
20 License along with GNU `sed'; see the file `COPYING.DOC'. If not,
21 write to the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02110-1301, USA.
24 There are no Cover Texts and no Invariant Sections; this text, along
25 with its equivalent in the printed manual, constitutes the Title Page.
27 File: sed.info, Node: Print bash environment, Next: Reverse chars of lines, Prev: Rename files to lower case, Up: Examples
29 Print `bash' Environment
30 ========================
32 This script strips the definition of the shell functions from the
33 output of the `set' Bourne-shell command.
40 # if no occurrence of "=()" print and load next line
44 # possible start of functions section
45 # save the line in case this is a var like FOO="() "
48 # if the next line has a brace, we quit because
49 # nothing comes after functions
56 # work on the new line now
61 File: sed.info, Node: Reverse chars of lines, Next: tac, Prev: Print bash environment, Up: Examples
63 Reverse Characters of Lines
64 ===========================
66 This script can be used to reverse the position of characters in
67 lines. The technique moves two characters at a time, hence it is
68 faster than more intuitive implementations.
70 Note the `tx' command before the definition of the label. This is
71 often needed to reset the flag that is tested by the `t' command.
73 Imaginative readers will find uses for this script. An example is
74 reversing the output of `banner'.(1)
80 # Reverse a line. Begin embedding the line between two newlines
85 # Move first character at the end. The regexp matches until
86 # there are zero or one characters between the markers
89 s/\(\n.\)\(.*\)\(.\n\)/\3\2\1/
92 # Remove the newline markers
95 ---------- Footnotes ----------
97 (1) This requires another script to pad the output of banner; for
102 banner -w $1 $2 $3 $4 |
103 sed -e :a -e '/^.\{0,'$1'\}$/ { s/$/ /; ba; }' |
104 ~/sedscripts/reverseline.sed
107 File: sed.info, Node: tac, Next: cat -n, Prev: Reverse chars of lines, Up: Examples
109 Reverse Lines of Files
110 ======================
112 This one begins a series of totally useless (yet interesting)
113 scripts emulating various Unix commands. This, in particular, is a
116 Note that on implementations other than GNU `sed' this script might
117 easily overflow internal buffers.
121 # reverse all lines of input, i.e. first line became last, ...
123 # from the second line, the buffer (which contains all previous lines)
124 # is *appended* to current line, so, the order will be reversed
127 # on the last line we're done -- print everything
130 # store everything on the buffer again
134 File: sed.info, Node: cat -n, Next: cat -b, Prev: tac, Up: Examples
139 This script replaces `cat -n'; in fact it formats its output exactly
142 Of course this is completely useless and for two reasons: first,
143 because somebody else did it in C, second, because the following
144 Bourne-shell script could be used for the same purpose and would be
148 sed -e "=" $@ | sed -e '
151 s/^ *\(......\)\n/\1 /
154 It uses `sed' to print the line number, then groups lines two by two
155 using `N'. Of course, this script does not teach as much as the one
158 The algorithm used for incrementing uses both buffers, so the line
159 is printed as soon as possible and then discarded. The number is split
160 so that changing digits go in a buffer and unchanged ones go in the
161 other; the changed digits are modified in a single step (using a `y'
162 command). The line number for the next line is then composed and
163 stored in the hold space, to be used in the next iteration.
167 # Prime the pump on the first line
171 # Add the correct line number before the pattern
175 # Format it and print it
177 s/^ *\(......\)\n/\1 /p
179 # Get the line number from hold space; add a zero
180 # if we're going to add a digit on the next line
185 # separate changing/unchanged digits with an x
188 # keep changing digits in hold space
191 y/0123456789/1234567890/
194 # keep unchanged digits in pattern space
197 # compose the new number, remove the newline implicitly added by G
203 File: sed.info, Node: cat -b, Next: wc -c, Prev: cat -n, Up: Examples
205 Numbering Non-blank Lines
206 =========================
208 Emulating `cat -b' is almost the same as `cat -n'--we only have to
209 select which lines are to be numbered and which are not.
211 The part that is common to this script and the previous one is not
212 commented to show how important it is to comment `sed' scripts
222 # Same as cat -n from now
228 s/^ *\(......\)\n/\1 /p
235 y/0123456789/1234567890/
243 File: sed.info, Node: wc -c, Next: wc -w, Prev: cat -b, Up: Examples
248 This script shows another way to do arithmetic with `sed'. In this
249 case we have to add possibly large numbers, so implementing this by
250 successive increments would not be feasible (and possibly even more
251 complicated to contrive than this script).
253 The approach is to map numbers to letters, kind of an abacus
254 implemented with `sed'. `a's are units, `b's are tens and so on: we
255 simply add the number of characters on the current line as units, and
256 then propagate the carry to tens, hundreds, and so on.
258 As usual, running totals are kept in hold space.
260 On the last line, we convert the abacus form back to decimal. For
261 the sake of variety, this is done with a loop rather than with some 80
262 `s' commands(1): first we convert units, removing `a's from the number;
263 then we rotate letters so that tens become `a's, and so on until no
268 # Add n+1 a's to hold space (+1 is for the newline)
274 # Do the carry. The t's and b's are not necessary,
275 # but they do speed up the thing
277 : a; s/aaaaaaaaaa/b/g; t b; b done
278 : b; s/bbbbbbbbbb/c/g; t c; b done
279 : c; s/cccccccccc/d/g; t d; b done
280 : d; s/dddddddddd/e/g; t e; b done
281 : e; s/eeeeeeeeee/f/g; t f; b done
282 : f; s/ffffffffff/g/g; t g; b done
283 : g; s/gggggggggg/h/g; t h; b done
292 # On the last line, convert back to decimal
311 ---------- Footnotes ----------
313 (1) Some implementations have a limit of 199 commands per script
316 File: sed.info, Node: wc -w, Next: wc -l, Prev: wc -c, Up: Examples
321 This script is almost the same as the previous one, once each of the
322 words on the line is converted to a single `a' (in the previous script
323 each letter was changed to an `a').
325 It is interesting that real `wc' programs have optimized loops for
326 `wc -c', so they are much slower at counting words rather than
327 characters. This script's bottleneck, instead, is arithmetic, and
328 hence the word-counting one is faster (it has to manage smaller
331 Again, the common parts are not commented to show the importance of
332 commenting `sed' scripts.
336 # Convert words to a's
342 # Append them to hold space
347 # From here on it is the same as in wc -c.
348 /aaaaaaaaaa/! bx; s/aaaaaaaaaa/b/g
349 /bbbbbbbbbb/! bx; s/bbbbbbbbbb/c/g
350 /cccccccccc/! bx; s/cccccccccc/d/g
351 /dddddddddd/! bx; s/dddddddddd/e/g
352 /eeeeeeeeee/! bx; s/eeeeeeeeee/f/g
353 /ffffffffff/! bx; s/ffffffffff/g/g
354 /gggggggggg/! bx; s/gggggggggg/h/g
374 File: sed.info, Node: wc -l, Next: head, Prev: wc -w, Up: Examples
379 No strange things are done now, because `sed' gives us `wc -l'
380 functionality for free!!! Look:
386 File: sed.info, Node: head, Next: tail, Prev: wc -l, Up: Examples
388 Printing the First Lines
389 ========================
391 This script is probably the simplest useful `sed' script. It
392 displays the first 10 lines of input; the number of displayed lines is
393 right before the `q' command.
399 File: sed.info, Node: tail, Next: uniq, Prev: head, Up: Examples
401 Printing the Last Lines
402 =======================
404 Printing the last N lines rather than the first is more complex but
405 indeed possible. N is encoded in the second line, before the bang
408 This script is similar to the `tac' script in that it keeps the
409 final output in the hold space and prints it at the end:
418 Mainly, the scripts keeps a window of 10 lines and slides it by
419 adding a line and deleting the oldest (the substitution command on the
420 second line works like a `D' command but does not restart the loop).
422 The "sliding window" technique is a very powerful way to write
423 efficient and complex `sed' scripts, because commands like `P' would
424 require a lot of work if implemented manually.
426 To introduce the technique, which is fully demonstrated in the rest
427 of this chapter and is based on the `N', `P' and `D' commands, here is
428 an implementation of `tail' using a simple "sliding window."
430 This looks complicated but in fact the working is the same as the
431 last script: after we have kicked in the appropriate number of lines,
432 however, we stop using the hold space to keep inter-line state, and
433 instead use `N' and `D' to slide pattern space by one line:
444 Note how the first, second and fourth line are inactive after the
445 first ten lines of input. After that, all the script does is: exiting
446 on the last line of input, appending the next input line to pattern
447 space, and removing the first line.
450 File: sed.info, Node: uniq, Next: uniq -d, Prev: tail, Up: Examples
452 Make Duplicate Lines Unique
453 ===========================
455 This is an example of the art of using the `N', `P' and `D'
456 commands, probably the most difficult to master.
462 # On the last line, print and exit
466 # The two lines are identical. Undo the effect of
472 # If the `N' command had added the last line, print and exit
475 # The lines are different; print the first and go
476 # back working on the second.
480 As you can see, we mantain a 2-line window using `P' and `D'. This
481 technique is often used in advanced `sed' scripts.
484 File: sed.info, Node: uniq -d, Next: uniq -u, Prev: uniq, Up: Examples
486 Print Duplicated Lines of Input
487 ===============================
489 This script prints only duplicated lines, like `uniq -d'.
496 # Print the first of the duplicated lines
500 # Loop until we get a different line
510 # The last line cannot be followed by duplicates
513 # Found a different one. Leave it alone in the pattern space
514 # and go back to the top, hunting its duplicates
518 File: sed.info, Node: uniq -u, Next: cat -s, Prev: uniq -d, Up: Examples
520 Remove All Duplicated Lines
521 ===========================
523 This script prints only unique lines, like `uniq -u'.
527 # Search for a duplicate line --- until that, print what you find.
536 # Got two equal lines in pattern space. At the
537 # end of the file we simply exit
540 # Else, we keep reading lines with `N' until we
541 # find a different one
548 # Remove the last instance of the duplicate line
549 # and go back to the top
553 File: sed.info, Node: cat -s, Prev: uniq -u, Up: Examples
555 Squeezing Blank Lines
556 =====================
558 As a final example, here are three scripts, of increasing complexity
559 and speed, that implement the same function as `cat -s', that is
560 squeezing blank lines.
562 The first leaves a blank line at the beginning and end if there are
567 # on empty lines, join with next
568 # Note there is a star in the regexp
575 # now, squeeze all '\n', this can be also done by:
580 This one is a bit more complex and removes all empty lines at the
581 beginning. It does leave a single blank line at end if one was there.
585 # delete all leading empty lines
590 # on an empty line we remove it and all the following
591 # empty lines, but one
599 This removes leading and trailing blank lines. It is also the
600 fastest. Note that loops are completely done with `n' and `b', without
601 relying on `sed' to restart the the script automatically at the end of
606 # delete all (leading) blanks
609 # get here: so there is a non empty
615 # got chars? print it again, etc...
618 # no, don't have chars: got an empty line
620 # get next, if last line we finish here so no trailing
621 # empty lines are written
623 # also empty? then ignore it, and get next... this will
624 # remove ALL empty lines
627 # all empty lines were deleted/ignored, but we have a non empty. As
628 # what we want to do is to squeeze, insert a blank line artificially
634 File: sed.info, Node: Limitations, Next: Other Resources, Prev: Examples, Up: Top
636 GNU `sed''s Limitations and Non-limitations
637 *******************************************
639 For those who want to write portable `sed' scripts, be aware that
640 some implementations have been known to limit line lengths (for the
641 pattern and hold spaces) to be no more than 4000 bytes. The POSIX
642 standard specifies that conforming `sed' implementations shall support
643 at least 8192 byte line lengths. GNU `sed' has no built-in limit on
644 line length; as long as it can `malloc()' more (virtual) memory, you
645 can feed or construct lines as long as you like.
647 However, recursion is used to handle subpatterns and indefinite
648 repetition. This means that the available stack space may limit the
649 size of the buffer that can be processed by certain patterns.
652 File: sed.info, Node: Other Resources, Next: Reporting Bugs, Prev: Limitations, Up: Top
654 Other Resources for Learning About `sed'
655 ****************************************
657 In addition to several books that have been written about `sed'
658 (either specifically or as chapters in books which discuss shell
659 programming), one can find out more about `sed' (including suggestions
660 of a few books) from the FAQ for the `sed-users' mailing list,
661 available from any of:
662 `http://www.student.northpark.edu/pemente/sed/sedfaq.html'
663 `http://sed.sf.net/grabbag/tutorials/sedfaq.html'
666 `http://www.student.northpark.edu/pemente/sed/index.htm' and
667 `http://sed.sf.net/grabbag', which include `sed' tutorials and other
668 `sed'-related goodies.
670 The `sed-users' mailing list itself maintained by Sven Guckes. To
671 subscribe, visit `http://groups.yahoo.com' and search for the
672 `sed-users' mailing list.
675 File: sed.info, Node: Reporting Bugs, Next: Extended regexps, Prev: Other Resources, Up: Top
680 Email bug reports to <bonzini@gnu.org>. Be sure to include the word
681 "sed" somewhere in the `Subject:' field. Also, please include the
682 output of `sed --version' in the body of your report if at all possible.
684 Please do not send a bug report like this:
686 while building frobme-1.3.4
688 error--> sed: file sedscr line 1: Unknown option to 's'
690 If GNU `sed' doesn't configure your favorite package, take a few
691 extra minutes to identify the specific problem and make a stand-alone
692 test case. Unlike other programs such as C compilers, making such test
693 cases for `sed' is quite simple.
695 A stand-alone test case includes all the data necessary to perform
696 the test, and the specific invocation of `sed' that causes the problem.
697 The smaller a stand-alone test case is, the better. A test case should
698 not involve something as far removed from `sed' as "try to configure
699 frobme-1.3.4". Yes, that is in principle enough information to look
700 for the bug, but that is not a very practical prospect.
702 Here are a few commonly reported bugs that are not bugs.
704 `N' command on the last line
705 Most versions of `sed' exit without printing anything when the `N'
706 command is issued on the last line of a file. GNU `sed' prints
707 pattern space before exiting unless of course the `-n' command
708 switch has been specified. This choice is by design.
710 For example, the behavior of
713 would depend on whether foo has an even or an odd number of
714 lines(1). Or, when writing a script to read the next few lines
715 following a pattern match, traditional implementations of `sed'
716 would force you to write something like
717 /foo/{ $!N; $!N; $!N; $!N; $!N; $!N; $!N; $!N; $!N }
720 /foo/{ N;N;N;N;N;N;N;N;N; }
722 In any case, the simplest workaround is to use `$d;N' in scripts
723 that rely on the traditional behavior, or to set the
724 `POSIXLY_CORRECT' variable to a non-empty value.
726 Regex syntax clashes (problems with backslashes)
727 `sed' uses the POSIX basic regular expression syntax. According to
728 the standard, the meaning of some escape sequences is undefined in
729 this syntax; notable in the case of `sed' are `\|', `\+', `\?',
730 `\`', `\'', `\<', `\>', `\b', `\B', `\w', and `\W'.
732 As in all GNU programs that use POSIX basic regular expressions,
733 `sed' interprets these escape sequences as special characters.
734 So, `x\+' matches one or more occurrences of `x'. `abc\|def'
735 matches either `abc' or `def'.
737 This syntax may cause problems when running scripts written for
738 other `sed's. Some `sed' programs have been written with the
739 assumption that `\|' and `\+' match the literal characters `|' and
740 `+'. Such scripts must be modified by removing the spurious
741 backslashes if they are to be used with modern implementations of
742 `sed', like GNU `sed'.
744 On the other hand, some scripts use s|abc\|def||g to remove
745 occurrences of _either_ `abc' or `def'. While this worked until
746 `sed' 4.0.x, newer versions interpret this as removing the string
747 `abc|def'. This is again undefined behavior according to POSIX,
748 and this interpretation is arguably more robust: older `sed's, for
749 example, required that the regex matcher parsed `\/' as `/' in the
750 common case of escaping a slash, which is again undefined
751 behavior; the new behavior avoids this, and this is good because
752 the regex matcher is only partially under our control.
754 In addition, this version of `sed' supports several escape
755 characters (some of which are multi-character) to insert
756 non-printable characters in scripts (`\a', `\c', `\d', `\o', `\r',
757 `\t', `\v', `\x'). These can cause similar problems with scripts
758 written for other `sed's.
760 `-i' clobbers read-only files
761 In short, `sed -i' will let you delete the contents of a read-only
762 file, and in general the `-i' option (*note Invocation: Invoking
763 sed.) lets you clobber protected files. This is not a bug, but
764 rather a consequence of how the Unix filesystem works.
766 The permissions on a file say what can happen to the data in that
767 file, while the permissions on a directory say what can happen to
768 the list of files in that directory. `sed -i' will not ever open
769 for writing a file that is already on disk. Rather, it will work
770 on a temporary file that is finally renamed to the original name:
771 if you rename or delete files, you're actually modifying the
772 contents of the directory, so the operation depends on the
773 permissions of the directory, not of the file. For this same
774 reason, `sed' does not let you use `-i' on a writeable file in a
775 read-only directory (but unbelievably nobody reports that as a
778 `0a' does not work (gives an error)
779 There is no line 0. 0 is a special address that is only used to
780 treat addresses like `0,/RE/' as active when the script starts: if
781 you write `1,/abc/d' and the first line includes the word `abc',
782 then that match would be ignored because address ranges must span
783 at least two lines (barring the end of the file); but what you
784 probably wanted is to delete every line up to the first one
785 including `abc', and this is obtained with `0,/abc/d'.
787 `[a-z]' is case insensitive
788 You are encountering problems with locales. POSIX mandates that
789 `[a-z]' uses the current locale's collation order - in C parlance,
790 that means using `strcoll(3)' instead of `strcmp(3)'. Some
791 locales have a case-insensitive collation order, others don't: one
792 of those that have problems is Estonian.
794 Another problem is that `[a-z]' tries to use collation symbols.
795 This only happens if you are on the GNU system, using GNU libc's
796 regular expression matcher instead of compiling the one supplied
797 with GNU sed. In a Danish locale, for example, the regular
798 expression `^[a-z]$' matches the string `aa', because this is a
799 single collating symbol that comes after `a' and before `b'; `ll'
800 behaves similarly in Spanish locales, or `ij' in Dutch locales.
802 To work around these problems, which may cause bugs in shell
803 scripts, set the `LC_COLLATE' and `LC_CTYPE' environment variables
806 ---------- Footnotes ----------
808 (1) which is the actual "bug" that prompted the change in behavior
811 File: sed.info, Node: Extended regexps, Next: Concept Index, Prev: Reporting Bugs, Up: Top
813 Extended regular expressions
814 ****************************
816 The only difference between basic and extended regular expressions
817 is in the behavior of a few characters: `?', `+', parentheses, and
818 braces (`{}'). While basic regular expressions require these to be
819 escaped if you want them to behave as special characters, when using
820 extended regular expressions you must escape them if you want them _to
821 match a literal character_.
825 becomes `abc\?' when using extended regular expressions. It
826 matches the literal string `abc?'.
829 becomes `c+' when using extended regular expressions. It matches
833 becomes `a{3,}' when using extended regular expressions. It
834 matches three or more `a's.
837 becomes `(abc){2,3}' when using extended regular expressions. It
838 matches either `abcabc' or `abcabcabc'.
841 becomes `(abc*)\1' when using extended regular expressions.
842 Backreferences must still be escaped when using extended regular
846 File: sed.info, Node: Concept Index, Next: Command and Option Index, Prev: Extended regexps, Up: Top
851 This is a general index of all issues discussed in this manual, with
852 the exception of the `sed' commands and command-line options.
856 * Additional reading about sed: Other Resources.
857 * ADDR1,+N: Addresses.
858 * ADDR1,~N: Addresses.
859 * Address, as a regular expression: Addresses.
860 * Address, last line: Addresses.
861 * Address, numeric: Addresses.
862 * Addresses, in sed scripts: Addresses.
863 * Append hold space to pattern space: Other Commands.
864 * Append next input line to pattern space: Other Commands.
865 * Append pattern space to hold space: Other Commands.
866 * Appending text after a line: Other Commands.
867 * Backreferences, in regular expressions: The "s" Command.
868 * Branch to a label, if s/// failed: Extended Commands.
869 * Branch to a label, if s/// succeeded: Programming Commands.
870 * Branch to a label, unconditionally: Programming Commands.
871 * Buffer spaces, pattern and hold: Execution Cycle.
872 * Bugs, reporting: Reporting Bugs.
873 * Case-insensitive matching: The "s" Command.
874 * Caveat -- #n on first line: Common Commands.
875 * Command groups: Common Commands.
876 * Comments, in scripts: Common Commands.
877 * Conditional branch <1>: Extended Commands.
878 * Conditional branch: Programming Commands.
879 * Copy hold space into pattern space: Other Commands.
880 * Copy pattern space into hold space: Other Commands.
881 * Delete first line from pattern space: Other Commands.
882 * Disabling autoprint, from command line: Invoking sed.
883 * empty regular expression: Addresses.
884 * Evaluate Bourne-shell commands: Extended Commands.
885 * Evaluate Bourne-shell commands, after substitution: The "s" Command.
886 * Exchange hold space with pattern space: Other Commands.
887 * Excluding lines: Addresses.
888 * Extended regular expressions, choosing: Invoking sed.
889 * Extended regular expressions, syntax: Extended regexps.
890 * Files to be processed as input: Invoking sed.
891 * Flow of control in scripts: Programming Commands.
892 * Global substitution: The "s" Command.
893 * GNU extensions, /dev/stderr file <1>: The "s" Command.
894 * GNU extensions, /dev/stderr file: Other Commands.
895 * GNU extensions, /dev/stdin file <1>: Other Commands.
896 * GNU extensions, /dev/stdin file: Extended Commands.
897 * GNU extensions, /dev/stdout file <1>: Invoking sed.
898 * GNU extensions, /dev/stdout file <2>: The "s" Command.
899 * GNU extensions, /dev/stdout file: Other Commands.
900 * GNU extensions, 0 address: Addresses.
901 * GNU extensions, 0,ADDR2 addressing: Addresses.
902 * GNU extensions, ADDR1,+N addressing: Addresses.
903 * GNU extensions, ADDR1,~N addressing: Addresses.
904 * GNU extensions, branch if s/// failed: Extended Commands.
905 * GNU extensions, case modifiers in s commands: The "s" Command.
906 * GNU extensions, checking for their presence: Extended Commands.
907 * GNU extensions, disabling: Invoking sed.
908 * GNU extensions, evaluating Bourne-shell commands <1>: Extended Commands.
909 * GNU extensions, evaluating Bourne-shell commands: The "s" Command.
910 * GNU extensions, extended regular expressions: Invoking sed.
911 * GNU extensions, g and NUMBER modifier interaction in s command: The "s" Command.
912 * GNU extensions, I modifier <1>: Addresses.
913 * GNU extensions, I modifier: The "s" Command.
914 * GNU extensions, in-place editing <1>: Reporting Bugs.
915 * GNU extensions, in-place editing: Invoking sed.
916 * GNU extensions, L command: Extended Commands.
917 * GNU extensions, M modifier: The "s" Command.
918 * GNU extensions, modifiers and the empty regular expression: Addresses.
919 * GNU extensions, N~M addresses: Addresses.
920 * GNU extensions, quitting silently: Extended Commands.
921 * GNU extensions, R command: Extended Commands.
922 * GNU extensions, reading a file a line at a time: Extended Commands.
923 * GNU extensions, reformatting paragraphs: Extended Commands.
924 * GNU extensions, returning an exit code <1>: Common Commands.
925 * GNU extensions, returning an exit code: Extended Commands.
926 * GNU extensions, setting line length: Other Commands.
927 * GNU extensions, special escapes <1>: Reporting Bugs.
928 * GNU extensions, special escapes: Escapes.
929 * GNU extensions, special two-address forms: Addresses.
930 * GNU extensions, subprocesses <1>: The "s" Command.
931 * GNU extensions, subprocesses: Extended Commands.
932 * GNU extensions, to basic regular expressions <1>: Reporting Bugs.
933 * GNU extensions, to basic regular expressions: Regular Expressions.
934 * GNU extensions, two addresses supported by most commands: Other Commands.
935 * GNU extensions, unlimited line length: Limitations.
936 * GNU extensions, writing first line to a file: Extended Commands.
937 * Goto, in scripts: Programming Commands.
938 * Greedy regular expression matching: Regular Expressions.
939 * Grouping commands: Common Commands.
940 * Hold space, appending from pattern space: Other Commands.
941 * Hold space, appending to pattern space: Other Commands.
942 * Hold space, copy into pattern space: Other Commands.
943 * Hold space, copying pattern space into: Other Commands.
944 * Hold space, definition: Execution Cycle.
945 * Hold space, exchange with pattern space: Other Commands.
946 * In-place editing: Reporting Bugs.
947 * In-place editing, activating: Invoking sed.
948 * In-place editing, Perl-style backup file names: Invoking sed.
949 * Inserting text before a line: Other Commands.
950 * Labels, in scripts: Programming Commands.
951 * Last line, selecting: Addresses.
952 * Line length, setting <1>: Invoking sed.
953 * Line length, setting: Other Commands.
954 * Line number, printing: Other Commands.
955 * Line selection: Addresses.
956 * Line, selecting by number: Addresses.
957 * Line, selecting by regular expression match: Addresses.
958 * Line, selecting last: Addresses.
959 * List pattern space: Other Commands.
960 * Mixing g and NUMBER modifiers in the s command: The "s" Command.
961 * Next input line, append to pattern space: Other Commands.
962 * Next input line, replace pattern space with: Common Commands.
963 * Non-bugs, in-place editing: Reporting Bugs.
964 * Non-bugs, N command on the last line: Reporting Bugs.
965 * Non-bugs, regex syntax clashes: Reporting Bugs.
966 * Parenthesized substrings: The "s" Command.
967 * Pattern space, definition: Execution Cycle.
968 * Perl-style regular expressions, multiline: Addresses.
969 * Portability, comments: Common Commands.
970 * Portability, line length limitations: Limitations.
971 * Portability, N command on the last line: Reporting Bugs.
972 * POSIXLY_CORRECT behavior, bracket expressions: Regular Expressions.
973 * POSIXLY_CORRECT behavior, enabling: Invoking sed.
974 * POSIXLY_CORRECT behavior, escapes: Escapes.
975 * POSIXLY_CORRECT behavior, N command: Reporting Bugs.
976 * Print first line from pattern space: Other Commands.
977 * Printing line number: Other Commands.
978 * Printing text unambiguously: Other Commands.
979 * Quitting <1>: Extended Commands.
980 * Quitting: Common Commands.
981 * Range of lines: Addresses.
982 * Range with start address of zero: Addresses.
983 * Read next input line: Common Commands.
984 * Read text from a file <1>: Extended Commands.
985 * Read text from a file: Other Commands.
986 * Reformat pattern space: Extended Commands.
987 * Reformatting paragraphs: Extended Commands.
988 * Replace hold space with copy of pattern space: Other Commands.
989 * Replace pattern space with copy of hold space: Other Commands.
990 * Replacing all text matching regexp in a line: The "s" Command.
991 * Replacing only Nth match of regexp in a line: The "s" Command.
992 * Replacing selected lines with other text: Other Commands.
993 * Requiring GNU sed: Extended Commands.
994 * Script structure: sed Programs.
995 * Script, from a file: Invoking sed.
996 * Script, from command line: Invoking sed.
997 * sed program structure: sed Programs.
998 * Selecting lines to process: Addresses.
999 * Selecting non-matching lines: Addresses.
1000 * Several lines, selecting: Addresses.
1001 * Slash character, in regular expressions: Addresses.
1002 * Spaces, pattern and hold: Execution Cycle.
1003 * Special addressing forms: Addresses.
1004 * Standard input, processing as input: Invoking sed.
1005 * Stream editor: Introduction.
1006 * Subprocesses <1>: Extended Commands.
1007 * Subprocesses: The "s" Command.
1008 * Substitution of text, options: The "s" Command.
1009 * Text, appending: Other Commands.
1010 * Text, deleting: Common Commands.
1011 * Text, insertion: Other Commands.
1012 * Text, printing: Common Commands.
1013 * Text, printing after substitution: The "s" Command.
1014 * Text, writing to a file after substitution: The "s" Command.
1015 * Transliteration: Other Commands.
1016 * Unbuffered I/O, choosing: Invoking sed.
1017 * Usage summary, printing: Invoking sed.
1018 * Version, printing: Invoking sed.
1019 * Working on separate files: Invoking sed.
1020 * Write first line to a file: Extended Commands.
1021 * Write to a file: Other Commands.
1022 * Zero, as range start address: Addresses.
1025 File: sed.info, Node: Command and Option Index, Prev: Concept Index, Up: Top
1027 Command and Option Index
1028 ************************
1030 This is an alphabetical list of all `sed' commands and command-line
1035 * # (comments): Common Commands.
1036 * --expression: Invoking sed.
1037 * --file: Invoking sed.
1038 * --help: Invoking sed.
1039 * --in-place: Invoking sed.
1040 * --line-length: Invoking sed.
1041 * --quiet: Invoking sed.
1042 * --regexp-extended: Invoking sed.
1043 * --silent: Invoking sed.
1044 * --unbuffered: Invoking sed.
1045 * --version: Invoking sed.
1051 * -n, forcing from within a script: Common Commands.
1054 * : (label) command: Programming Commands.
1055 * = (print line number) command: Other Commands.
1056 * a (append text lines) command: Other Commands.
1057 * b (branch) command: Programming Commands.
1058 * c (change to text lines) command: Other Commands.
1059 * D (delete first line) command: Other Commands.
1060 * d (delete) command: Common Commands.
1061 * e (evaluate) command: Extended Commands.
1062 * G (appending Get) command: Other Commands.
1063 * g (get) command: Other Commands.
1064 * H (append Hold) command: Other Commands.
1065 * h (hold) command: Other Commands.
1066 * i (insert text lines) command: Other Commands.
1067 * L (fLow paragraphs) command: Extended Commands.
1068 * l (list unambiguously) command: Other Commands.
1069 * N (append Next line) command: Other Commands.
1070 * n (next-line) command: Common Commands.
1071 * P (print first line) command: Other Commands.
1072 * p (print) command: Common Commands.
1073 * q (quit) command: Common Commands.
1074 * Q (silent Quit) command: Extended Commands.
1075 * r (read file) command: Other Commands.
1076 * R (read line) command: Extended Commands.
1077 * s command, option flags: The "s" Command.
1078 * T (test and branch if failed) command: Extended Commands.
1079 * t (test and branch if successful) command: Programming Commands.
1080 * v (version) command: Extended Commands.
1081 * w (write file) command: Other Commands.
1082 * W (write first line) command: Extended Commands.
1083 * x (eXchange) command: Other Commands.
1084 * y (transliterate) command: Other Commands.
1085 * {} command grouping: Common Commands.