Date: Tue, 27 Mar 2007 11:59:34 +0400 From: Yar Tikhiy <yar@comp.chem.msu.su> To: Joseph Koshy <joseph.koshy@gmail.com> Cc: hackers@freebsd.org Subject: Re: sed -i Message-ID: <20070327075934.GA10930@comp.chem.msu.su> In-Reply-To: <84dead720703260827q29ed7f26hd79dde461fe50d9b@mail.gmail.com> References: <20070326135106.GG60831@comp.chem.msu.su> <84dead720703260827q29ed7f26hd79dde461fe50d9b@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 26, 2007 at 08:57:14PM +0530, Joseph Koshy wrote: > >Recently noticed that our sed(1) differs from its GNU > >analog in that in -i mode it considers all files as a > >single sequence of lines while the latter treats each file > >independently. The in-line mode isn't in POSIX, so it isn't > >really clear which way is correct. > > Aren't sed's addresses required to be cumulative across its > input files? > > http://www.opengroup.org/onlinepubs/009695399/utilities/sed.html That makes sense for filter mode because it's equvalent to concatenating the files in advance: cat files ... | sed expression OTOH, in-place mode selected by a -i option can be seen as follows: for f in files ...; do sed expression < $f > $f.tmp && mv $f $f.bak && mv $f.tmp $f done I.e., each file preserves its individuality. This can be at logical conflict with cumulative addresses across all files. -- Yar
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070327075934.GA10930>