With zsh:
Code:
zsh 4.3.4 % host=(${$(grep -F Host file)//[^0-9.]/})
zsh 4.3.4 % print $host[1]
192.168.2.2
zsh 4.3.4 % print $host[2]
192.168.2.4
With bash:
Code:
bash 3.2.13(1) $ while read;do
> [[ "$REPLY" == *Host* ]]&&host=($host ${REPLY//[^0-9.]/})
> done<file
bash 3.2.13(1) $ echo ${host[0]}
192.168.2.2
bash 3.2.13(1) $ echo ${host[1]}
192.168.2.4
|