/ Published in: Bash
Bash script to list all devices (ip and hostname) connected to your local network.
Some formatting is done, and a summary is printed at the end.
Requires nmap.
Some formatting is done, and a summary is printed at the end.
Requires nmap.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/bin/bash NETWORK="192.168.1.0/24" #Output formatting BOLD="\033[1m" WHITE_ON_GREY="\033[100;97m" RESET="\033[0m" sudo nmap -sn -PO "$NETWORK" \ | grep -oE "[a-zA-Z0-9\.\-]+\s\(([0-9]{1,3}\.){3}[0-9]{1,3}\)" \ | sed 's/[)(]//g' \ | awk -v bold="$BOLD" -v fg="$WHITE_ON_GREY" -v reset="$RESET" -f <(cat - <<-'EOD' BEGIN{ OFS="\t"; } { print $2,$1; } END{ print bold fg NR" Hosts are up" reset; } EOD )