[LBo] looking for command
Chris F.A. Johnson
cfajohnson at teksavvy.com
Sun Mar 18 05:54:24 CET 2007
On Sat, 17 Mar 2007, Ray wrote:
>
> I'm looking for a command that will provide my own IP address
> suitable to pass as a commandline paramater to another program.
> I am aware of ifconfig and arp and if need be I can parse their
> output, (or just do it manually), but if there is an easier way....
> What I want is a command that just returns my internal ip address.
> i.e. command foo -> 192.168.0.104
> is there any such thing?
if=eth0 ## adjust to taste
temp=$(ifconfig "$if")
temp=${temp#*"$sep"}
ip=${temp%% *}
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
More information about the QnA
mailing list