Stephen Harris wrote: > On Fri, May 23, 2008 at 06:02:29PM +0200, Mihai T. Lazarescu wrote: > >> On Fri, May 23, 2008 at 08:41:19AM -0700, Scott McClanahan wrote: >> >>> 184.108.40.206 foo >>> 10.10.10.10 bar bar2 >>> 100.100.100.100 foobar foobar2 foobar3 >>> > > >>> == After == >>> > > >>> 220.127.116.11 foo.contoso.com >>> 10.10.10.10 bar.contoso.com bar2 >>> 100.100.100.100 foobar.contoso.com foobar2 foobar3 >>> >>> Any advice on how to pull this off? Thanks. >>> >> sed 's/ /.contoso.com ' >> > > That works because we've explicity been told > <ip address> <tab> <short hostname> <space> <short hostname alias> > so the first space is a good place to switch. > > More generally, if there's possibly multiple spaces or tabs in multiple > places this might work: > > sed 's/^\([^ ]*[ ]*[^ ]*\)\([ ]*.*\)$/\1.contoso.com\2/' > > (where there's a space *and* a TAB inside each of the [ ] ) > The above version easier to read and "copy paste". Space is space and tabe is \t sed 's/^\([^ \t]*[ \t]*[^ \t]*\)\([ \t]*.*\)$/\1.contoso.com\2/'