[CentOS] sed

Fri May 23 16:02:29 UTC 2008
Mihai T. Lazarescu <mtlagm at gmail.com>

On Fri, May 23, 2008 at 08:41:19AM -0700, Scott McClanahan wrote:

> Not specific to CentOS but I know you guys would be really helpful anyhow. 
> Basically, I have a file which has been editted in the past very similarly to
> the hosts file only now I want to use it as a hosts file and need to run some
> fancy sed to massage the data into shape.  Currently, the data in the file is
> in the form of <ip address> <tab> <short hostname> <space> <short hostname
> alias>.  In some cases there may not be any aliases so the end of line would be
> right after the short hostname (no space at the end either).  In other cases
> there could be many space separated short hostname aliases.  What I have been
> trying to do without success is add our domain name to the first string after
> the ip address and tab character.  As an example,
> == Before ==
>    foo
>    bar bar2
>    foobar foobar2 foobar3
> == After ==
>    foo.contoso.com
>    bar.contoso.com bar2
>    foobar.contoso.com foobar2 foobar3
> Any advice on how to pull this off?  Thanks.

sed 's/ /.contoso.com '