«
back to MAIN FAQ
SED FAQ CONTENTS:
1.
GENERAL INFORMATION
1.1. Introduction - How this FAQ is organized
1.2. Latest version of the sed FAQ
1.3. FAQ revision information
1.4. How do I add a question/answer to the sed FAQ?
1.5. FAQ abbreviations
1.6. Credits and acknowledgements
1.7. Standard disclaimers
2.
BASIC SED
2.1. What is sed?
2.2. What versions of sed are there, and where can I get them?
2.2.1.
Free versions
2.2.1.1. Unix platforms
2.2.1.2. OS/2
2.2.1.3. Microsoft Windows (Win3x, Win9x, WinNT, Win2K)
2.2.1.4. MS-DOS
2.2.1.5. CP/M
2.2.2.
Shareware and Commercial versions
2.2.2.1. Unix platforms
2.2.2.2. OS/2
2.2.2.3. Windows 95/98, Windows NT, Windows 2000
2.2.2.4. MS-DOS
2.3.
Where can I learn to use sed?
2.3.1. Books
2.3.2. Mailing list
2.3.3. Tutorials, electronic text
2.3.4. General web and ftp sites
3.
TECHNICAL
3.1. More detailed explanation of basic sed
3.2. Common one-line sed scripts. How do I . . . ?
3.3. Addressing and address ranges
3.4. [reserved]
3.5. [reserved]
3.6. Notes about s2p, the sed-to-perl translator
3.7. GNU/POSIX extensions to regular expressions
4.
EXAMPLES
4.1. How do I perform a case-insensitive search?
4.2. How do I make changes in only part of a file?
4.3. How do I change only the first occurrence of a pattern?
4.4. How do I make substitutions in every file in a directory, or in a complete directory tree?
4.4.1 - Perl solution
4.4.2 - Unix solution
4.4.3 - DOS solution
4.5. How do I parse a comma-delimited data file?
4.6. How do I insert a newline into the RHS of a substitution?
4.7. How do I represent control-codes or non-printable characters?
4.8. How do I read environment variables with sed?
4.8.1. - on Unix platforms
4.8.2. - on MS-DOS or 4DOS platforms
4.9. How do I export or pass variables back into the environment?
4.9.1. - on Unix platforms
4.9.2. - on MS-DOS or 4DOS platforms
4.10. How do I handle shell quoting in sed?
4.11. How do I delete a block of text if the block contains a certain regular expression?
4.12. How do I locate/print a paragraph of text if the paragraph contains a certain regular expression?
4.13. How do I delete a block of _specific_ consecutive lines?
4.14. How do I read (insert/add) a file at the top of a textfile?
4.15. How do I address all the lines between RE1 and RE2, excluding the lines themselves?
4.16. How do I replace "/some/UNIX/path" in a substitution?
4.17. How do I replace "C:\SOME\DOS\PATH" in a substitution?
4.18. How do I convert files with toggle characters, like +this+, to look like [i]this[/i]?
4.19. How do I delete only the first occurrence of a pattern?
4.20. How do I commify a string of numbers?
5.
WHY ISN'T THIS WORKING?
5.1. Why don't my variables like $var get expanded in my sed script?
5.2. I'm using 'p' to print, but I have duplicate lines sometimes.
5.3. Why does my DOS version of sed process a file part-way through and then quit?
5.4. My RE isn't matching/deleting what I want it to. (Or, "Greedy vs. stingy pattern matching")
5.5. What is CSDPMI*B.ZIP and why do I need it?
5.6. Where are the man pages for GNU sed?
5.7. How do I tell what version of sed I am using?
5.8. Does sed issue an exit code?
5.9. The 'r' command isn't inserting the file into the text.
5.10. Why can't I match or delete a newline using the \n escape sequence? Why can't I match 2 or more lines using \n?
5.11. My script aborts with an error message, "event not found".
6.
OTHER ISSUES
6.1. I have a problem that stumps me. Where can I get help?
6.2. How does sed compare with awk, perl, and other utilities?
6.3. When should I use sed?
6.4. When should I NOT use sed?
6.5. When should I ignore sed and use Awk or Perl instead?
6.6. Known limitations among sed versions
6.6.1. Maximum line length
6.6.2. Maximum size for all buffers (pattern space + hold space)
6.6.3. Maximum number of files that can be read with read command
6.6.4. Maximum number of files that can be written with 'w' command
6.6.5. Limits on length of label names
6.6.6. Limits on length of write-file names
6.6.7. Limits on branch/jump commands
6.7. Known bugs among sed versions
6.8. Known incompatibilities between sed versions
6.8.1. Issuing commands from the command line
6.8.2. Using comments (prefixed by the '#' sign)
6.8.3. Special syntax in REs
6.8.4. Word boundaries
6.8.5. Range addressing with GNU sed and HHsed
6.8.6. Commands which operate differently