Re: sed problems: Inserting a line at the FIRST match only
On Thu, 24 Oct 1996, Christoph Lameter wrote:
> I have a problem of inserting a font path into /etc/X11/XF86Config at
> a specific location after the last FontPath statement in the first
> section of XF86Config.
>
> I cannot figure out how to convince sed to only do something at the
> first location and EndSection occurs. Can somebody help me?
kludgy hack time:
lastfontpath=`grep FontPath /etc/X11/XF86Config | tail -1`
will give the last line containing "FontPath" in lastfontpath.
>From here you can:
1. Search for that with sed - you might need to escape certain chars
like / first (sed -e 's:/:\/:g') - and somehow insert whatever you need
to after that line.
2. cat all lines UP TO 'lastfontpath' to $TMPFILE.0
put whatever you need to in $TMPFILE.1
cat all lines AFTER 'lastfontpath' to $TMPFILE.2
cat $TMPFILE.0 $TMPFILE.1 $TMPFILE.2 > /etc/X11/XF86Config
rm -f $TMPFILE.0 $TMPFILE.1 $TMPFILE.2
Craig
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com
Reply to: