Skip to content

Instantly share code, notes, and snippets.

@mccabe615
Created February 3, 2019 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mccabe615/563b30600b62b54a4df4c617afc955c9 to your computer and use it in GitHub Desktop.
Save mccabe615/563b30600b62b54a4df4c617afc955c9 to your computer and use it in GitHub Desktop.
Determine number of hosts for subnet from file
while IFS="" read -r p || [ -n "$p" ];
do
printf '%s' "$p -- Hosts: ";
subnetcalc $p|grep "Max. Hosts"|awk '{ print $4 }';
done < hosts.txt
# while IFS="" read -r p || [ -n "$p" ]; do printf '%s' "$p -- Hosts: "; subnetcalc $p|grep "Max. Hosts"|awk '{ print $4 }'; done < hosts.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment