You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 lines
431 B

#!/bin/bash
nmap -sn `ip route | tail -1 | cut -d ' ' -f1` | sed -n 'n;p' | cut -c 22- | head -n -1 | awk '{tmp=$1; $1=$2; $2=tmp; gsub("\\(","",$1); gsub("\\)","",$1); printf "%-15s %s\n", $1, $2}' | sed 's/^ *//'
# sed -n 'n;p' => FILTER odd lines
# awk '{tmp=$1; $1=$2; $2=tmp; gsub("\\(","",$1); gsub("\\)","",$1); printf "%-15s %s\n", $1, $2}' => SWAP words and remove parenthesis
# sed 's/^ *//' => REMOVE starting spaced