[ Date Index ]
[ Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
Re: [LUG] bash shell script question
- To: list@xxxxxxxxxxxxx
- Subject: Re: [LUG] bash shell script question
- From: Martijn Grooten <martijn@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 2 Jan 2015 16:57:53 +0000
- Content-disposition: inline
- Delivered-to: dclug@xxxxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dcglug.org.uk; s=1412586362; h=Sender:Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:List-Unsubscribe:List-Id:Reply-To:Subject:In-Reply-To:MIME-Version:References:Message-ID:To:From:Date; bh=iL8X140jJ5I2CN06+HR1jSQpZsLZbc7MjdLXxdjkIb8=; b=gnR77gV3RcP/9xzkE0L9KxXMxJAeT422ZfB7MvzzPbdCN0yYlkMJjyKVNQBCfpQpeIC+gjzYBBGb7gRkMoA9HgxvN8q9o+gxDYDCmj6ERo17y25Yo6UiMdciybjR4j6HK5ZDjRln4dS3y5+lJtpBexmdcIUyQae9F0ygkPqcwhI=;
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=lapsedordinary.net; s=mail; t=1420217873; bh=LqmwpQ1Sf+beW/rCK8OzuX2ImA/vW9C408sZxBmyZak=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=THfdFbHre2OrOPuNGJyTSNU7Yhvu1tltCHsBERt4kCxyMOXAsaLdqkfdtiJNOaj7f cFsa2ANWrs39ZZ8gLZ55GMlpUoqdxP5mXhzi/wQfHddAqjRm5w0EiVaQwuAefYbPft HNiHttMjvPWVYCSxBfpBP6p8HG88IP1m2MNu/mUk=
On Fri, Jan 02, 2015 at 04:47:41PM +0000, Paul Sutton wrote:
> 1. Put the out put to hostname -I as a variable and display that OR
> 2 put the output as an environment variable e.g $HOSTNAME and
> display that
>
> Just not sure on HOW to do this
hostname=`hostname -I`; echo "Hostname: $hostname"
Another way, which works well to get rid of line breaks in bash scripts
in general, is
echo "hostname:"| tr "\n" " "; hostname -I
Here 'tr' replaces all instances of "\n" (i.e. a line break) by spaces.
Martijn.
--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq