Originally written and designed for Unix, sed has been ported to MS-DOS, Windows, OS/2, and other operating systems. Sed is a non-interactive editor that works from a command line; it's not a GUI Windows app. Sed changes blocks of text on the fly, without making you open up a screen, push a cursor around, and press
DELETEorINSERTorENTERor function keys."Hey," you might ask. "All word processors have a find-and-replace feature."
Not like this. Sed is extremely powerful, and you can do things in sed that you can't do in any standard word processor. And because sed is external to the word processor and comes with every Unix system in the world, once you learn sed you'll have a very handy tool in your toolkit, even if (like me) you rarely use Unix.
How it works: You feed sed a script of editing commands (like, "change every line that begins with a colon to such-and-such") and sed sends your revised text to the screen. To save the revisions on disk, use the redirection arrow, >
newfile.txt. Sample syntax:sed "one-or-two-sed-commands" input.file >newfile.txt sed -f bigger_sed.script input.file >newfile.txtThis page is an attempt to collect my FAQ (Frequently Asked Questions) files and my favorite sed utilities and introductions for novices. The text files are for any sed user; the binaries are for DOS/Windows users.
March 2001 update: Precompiled binaries of ssed (super-sed) for Win32 are here. The "official" version of my sed pages is at North Park University. They are mirrored at Cornerstone, which is often up-to-date. The pages at North Park are always the most recent.
|
|
| popular sed binaries for MS-DOS |
|---|
All of these versions will run in a DOS window or in a full-screen DOS session under Microsoft Windows.
| A Table of Differences among DOS versions of SED | |||||||
| This version of sed supports . . . . | ssed | gsed302.80 | gsed302 | gsed205 | gsed103 | hhsed | sedmod |
|---|---|---|---|---|---|---|---|
| Win95 long filenames | Y | Y | Y | Y | Y | Y¹ | N |
| newlines in s/find/rep/ replacement text via \n | Y | Y | N | N | Y | Y | Y |
| represent tabs by \t | Y | Y | N | N | Y | Y | Y |
| "a append-on-same-line" (for a,i,c commands) | Y | Y | N | N | N | Y | Y |
| interval expressions like \{m,n\} | Y | Y | Y | Y | N | Y² | N |
| ignore case /flag/i or switch (-i) | Y | Y | Y | N | N | N | Y |
| hex code entry via \xHH | Y | Y | N | N | Y | Y | N |
| unlimited line length or buffer size | Y | Y | Y | Y | 64K | 4K | 4K |
| numeric argument flags in s/ubsti/tution/5 | Y | Y | Y | Y | Y | Y | N |
| OR searches with \|, like /this\|or\|this/ | Y | Y | Y | Y | Y | N | N |
| periodic line matching with M~N | Y | Y | Y | Y | N | N | N |
| word arguments with $1, $2, ... $8, $9 | N | N | N | N | N | N | Y |
| case change with \L, \l, \U, \u, \E, \e | Y | N | N | N | N | N | Y |
| can run in MS-DOS mode, fully outside of Windows | N | Y | Y | N | N | Y³ | Y |
(¹) File SED15X.ZIP does not support Win95 long filenames. However, a version of SED15.EXE compiled with Mingw32 does support long filenames and is available here.
(²) Interval range of \{0,n\} not supported in sed15.
(³) sed15 will run in MS-DOS mode; the version compiled with Mingw32 will not.
| mailing list for sed users |
|---|
If you are interested in learning more about sed (its syntax, using regular expressions, etc.) you are welcome to subscribe to a sed-oriented mailing list. In fact, there are two mailing lists about sed: one in English named sed-users, moderated by Sven Guckes; and one in Portuguese named sed-BR, moderated by Aurelio Marinho Jargas. The average volume of mail for sed-users is about 10 messages a week.
| related batch editing files |
|---|
Console/command-line appsWindows apps
- MiniTrue, v2.02 - by Andrew Pipkin. MiniTrue ("mtr") is a truly powerful text view and replacement tool. Search/Replace syntax uses Perl-style regular expressions, with a non-sed style syntax ("find_regex" = "replace"). Editing commands can be entered from the DOS command line or from a script file. MT supports direct alteration of input files (unlike sed), directory recursion (ditto), prompted replacement (ditto!), video highlighting (ditto!!), multi-line searching (ditto!!!), and handling of compressed archive files like .ZIP, .ARJ, .LHA, and others (yowza!). Handles files and lines of unlimited size or length. Best of all, MT is distributed as freeware, with the source code available. Not a standard Unix utility, but in several ways it's better than sed.
- snr506.zip - Search'N'Replace v5.06, by Tom Lundin. Doesn't use Unix "regular expressions", but possibly THE most powerful tool ever written for doing massive search-and-replace operations on any file, including binary code and .EXE files. Find/replace commands may be up to 4,999 chars in length, and up to 2,500 find/replace commands may be entered in a single table, with all commands processed simultaneously. Supports variable-length search patterns, various wildcards, and multiple toggle-type (on/off) flags. $50 shareware, but worth every penny if you need full control over binary or nontext files. (filesize: 100k)
- snr61sw.zip - Search'N'Replace v6.1 (shareware zip file). This is a more recent version of SNR than the other. Includes 32-bit versions for DOS and a GUI version for Win95/98/NT (with long filename support). Requires 486 or higher to run. Shareware price is raised to $60. (filesize: 417k)
- iCarte Lightning - ver. 1.3.3, by iCarte. This is a Win32 product which handles multiple search files, multiple files to exclude, and multiple strings to find and replace. Distributed as freeware, but without source code. Originally used to fixing HTML files; worth getting if you prefer GUIs.
- TextWiz - ver. 1.3. Another Win32 program distributed as freeware. Features include multi-line find/replace in any number of files from the same folder; optionally create back-up files; optionally just searches for text in multiple files, returning a list of filenames; view files in TextWiz, in Notepad, or in a default application; counts lines/words/chars, more.
- InfoRapid Search & Replace - ver. 3.0c. A Win32 app with built-in converters for searching and previewing HTML/RTF documents. In pure text files, the found passages can be replaced after the search is over. A preview displays hits in highlighting. InfoRapid can also search WinWord, Excel, Lotus, WordPerfect, etc. and preview them in their original layout. InfoRapid Search & Replace is distributed as freeware for private use; commercial use requires a small fee. Replacements can be performed in binary files as well as text.
- XReplace-32 - version 2.21, for Win 95/98/NT, by Vestris, Inc. A 32-bit Windows utility for performing multiple replacements in multiple files in multiple directories. XReplace supports regular expressions, and search patterns can cross line boundaries. Shareware from Switzerland, US$39.
Thanks for visiting. Hope you found what you wanted!
Eric Pement, sed FAQ maintainerLast revised Mar. 23, 2001