Results 1 to 1 of 1
Hi all,
I've got this piece of shell script:
Code:
# Set up array for all IP addresses
IPADDRS=""
COUNTER=0
for EACH in `ifconfig -a`; do
# Look for four ...
- 03-01-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 1
Regex/egrep help
Hi all,
I've got this piece of shell script:
It should look through the output of `ifconfig -a` and place IP addresses into the IPADDRS array. It did work...But now it doesn't, but I'm not sure why...Code:# Set up array for all IP addresses IPADDRS="" COUNTER=0 for EACH in `ifconfig -a`; do # Look for four sets of grouped numbers separated by periods. # Groups are between 1 and 3 digets in size and consist of numbers only. IPADDRS[$COUNTER]=`echo $EACH | egrep [0-9]\{1,3\}"\."[0-9]\{1,3\}"\."[0-9]\{1,3\}"\."[0-9]\{1,3\}` # Increment counter COUNTER=$(( $COUNTER + 1 )) done
Even if I strip out the array stuff, it's not echo'ing the IP addresses...
I'm using OpenSolaris 2009.06 for this particular project. The same expression works on my Mac though...
Any ideas?
Thanks,
Ben


Reply With Quote