Skip to content

Instantly share code, notes, and snippets.

View borg1622's full-sized avatar

Dirk Osburg borg1622

  • Munich
  • 13:38 (UTC +02:00)
View GitHub Profile
@borg1622
borg1622 / broadcast_calc.sh
Created May 27, 2019 10:03 — forked from cskeeters/broadcast_calc.sh
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