Wednesday, 22 October 2008

Getting your IP address

There are a lot of "What's your IP" services on the net. This is not about those.

I had a need today to load a shell script with the IP address of my interface at work. ifconfig told me, but it was noisy. So I crafted the following one-liner on the command line then used it in the shell script (depending on your distro, you might have better ways, but this solved an immediate need):

IP=`ifconfig en0 | grep -w inet | cut -d ' ' -f 2`

Posted by caffeinated at 12:40 PM in nerdery
« October »
SunMonTueWedThuFriSat
   1234
567891011
12131415161718
19202122232425
262728293031