Date: Fri, 16 Jan 2004 18:37:38 -0800 (PST) From: Jean-Marc Zucconi <jmz@dalai-zebu.org> To: Brett Glass <brett@lariat.org> Cc: questions@freebsd.org Subject: Re: General UNIX puzzle Message-ID: <200401170237.i0H2bcb3049359@freefall.freebsd.org> In-Reply-To: <6.0.0.22.2.20040116192550.05046df8@localhost> References: <6.0.0.22.2.20040116192550.05046df8@localhost>
next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> Brett Glass writes:
> I was asked a good question today about how to do some simple tasks using
> standard UNIX tools, and am curious what answers people on the list might
> come up with.
> What are the simplest, most efficient ways to:
> 1) Delete the Nth line from a text file?
sed -e Nd <file
> 2) Insert a specified line in a file after the Nth line, leaving the rest
> of the text the same?
sed -e 'Na\
line of text' <file
> 3) Delete the first line containing a particular string?
awk '{if (/string/ && i==0) i++; else print $0}'<file
> 4) Insert a specified line after the first line containing a particular
> string, leaving the rest of the file the same?
You can infer it by yourself after 3)
Jean-Marc
--
Jean-Marc Zucconi -- PGP Key: finger jmz@FreeBSD.org [KeyID: 400B38E9]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401170237.i0H2bcb3049359>
