Re: Insert the content of a file (with command r?)
Laurent Le Brun <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <CA+j=sHAO1Stq-omw34-qYf5eqV_eCPdygkCysFZD-ZaNEcaTcQ@mail.gmail.com> |
On Tue, Jul 24, 2012 at 12:05 PM, Laurent Le Brun <[email protected]> wrote: > I'd like to insert the content of a file when the input matches some regexp. > It tried this simple script: /regexp/r file.txt > It works fine, except that it's inserting the content of the file > after the line matching the regexp. I'd like to insert it BEFORE > instead. Thanks for the replies! I've just found a solution by accident: /regexp/e cat file.txt Documentation is not very clear here: "If a parameter is specified, instead, the e command interprets it as a command and sends its output to the output stream (like r does)." (http://www.gnu.org/software/sed/manual/sed.html#Extended-Commands) There's a difference, as r sends the output at the end of a cycle, while e sends it immediately. -- Laurent