Try this one
Code:
#!/bin/bash
clear
#
echo 'Restarting Network'
/etc/init.d/networking restart
echo 'Displaying IP Address'
ip addr show eth0 | grep inet | awk '{print $2 }'
read
'|' is the pipe symbol and forwards output to next commands input
grep searches for a string. I guess you only want the ip address
awk is for printing stuff nice and other things. We want the second field which holds the ip.
read just waits for input. This makes sure the window stays open.
You get the ipv4 as well as the ipv6 address. Suite to your likings.
Quote:
Originally Posted by Joeblah
zhjim,
I want to thank you for the taking the time to help me with this. I know its trivial for you but it is also what makes me want to get into linux when I know people are willing to help through all the entry level questions.
|
You're welcome. We all started somewhere. I'd say on linuxquestions you'll find a lot of helpful people as long as you adopt some simple rules. Just like in any forum. Be nice, be as explicit as it can be, and have a crate of beer in reach
If you feel so you can click the "Was that post helpfull" to fill my karma a bit.