- sed reads from a file or from its standard input, and outputs to its standard output. You will generally want to redirect that into a file. sed does not get along with non-text files, like executables and FrameMaker files. If you need to edit those, use a binary editor like hexl-mode in emacs.
Example > sed ‘s/fubar/foobar/’ filename > newfilename
- The single quotes protect almost everything from the shell. In csh or tcsh, you still have to watch out for exclamation marks, but other than that, you’re safe.
- The GNU version of sed generally has better error messages:
gsed 's/fubar/foobar' filename gsed: Unterminated `s' command
So, if you’re having problems getting sed syntax correct, switch to gsed for a while.
More can be found at http://www.cs.hmc.edu/tech_docs/qref/sed.html#regexp and