Re: Sed, insert a file current line
From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 11/20/03
- Next message: David: "Re: setup dhcp server"
- Previous message: Beowulf: "Re: lightweight linux for low power cpu's"
- In reply to: * Tong *: "Sed, insert a file current line"
- Next in thread: Tapani Tarvainen: "Re: Sed, insert a file current line"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Nov 2003 22:49:22 -0800
* Tong * <sun_tong@users.sourceforge.net> wrote in message news:<292fd8a71b89d833cc53eb5191e5e726@news.teranews.com>...
> Hi,
>
> It is quite easy to include/append a file after a criteria line in sed by
>
> '/criteria/ r file'
>
> command. But is it possible to insert a file before a criteria line in
> sed? If not, is there another simple tool (not perl) that can do it?
>
> Thanks
sed -e '
/criteria/{
x;p
r file
x
}
h
' yourfile
note: this is not thoroughly tested as consecutive /criteria/ lines
will misbehave.
- Next message: David: "Re: setup dhcp server"
- Previous message: Beowulf: "Re: lightweight linux for low power cpu's"
- In reply to: * Tong *: "Sed, insert a file current line"
- Next in thread: Tapani Tarvainen: "Re: Sed, insert a file current line"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|