Skip to content

Instantly share code, notes, and snippets.

@KristianLyng
Created March 13, 2012 14:28
Show Gist options
  • Select an option

  • Save KristianLyng/2029114 to your computer and use it in GitHub Desktop.

Select an option

Save KristianLyng/2029114 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Simply lists all IPs currently in the chef-setup in a sorted manner
knife status | gawk -v FS="," -v f=0 '
{
if (f == 0) {
for (a=1; a<=NF; a++) {
if ($a ~ /[0-9][0-9]+\.[0-9]+/) {
f = a;
break;
}
}
}
tmp = $f
gsub("[ ,]","", tmp);
ip[i++] = tmp
}
END {
n=asort(ip)
for (a=1; a<n; a++) {
print "ip: " ip[a];
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment