Skip to content

Instantly share code, notes, and snippets.

View platu's full-sized avatar

Philippe Latu platu

View GitHub Profile
@cskeeters
cskeeters / broadcast_calc.sh
Created December 8, 2016 19:17
Bash script for calculating network and broadcast addresses from ip and netmask or CIDR Notation
#!/bin/bash
# Calculates network and broadcast based on supplied ip address and netmask
# Usage: broadcast_calc.sh 192.168.0.1 255.255.255.0
# Usage: broadcast_calc.sh 192.168.0.1/24
tonum() {
if [[ $1 =~ ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+) ]]; then