1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/linuxdash_ynh.git synced 2024-09-03 19:36:07 +02:00
linuxdash_ynh/sources/server/modules/shell_files/arp_cache.sh

17 lines
No EOL
424 B
Bash
Executable file

#!/bin/bash
arpCommand=$(command -v arp)
result=$($arpCommand | awk 'BEGIN {print "["} NR>1 \
{print "{ \"address\": \"" $1 "\", " \
"\"hw_type\": \"" $2 "\", " \
"\"hw_address\": \"" $3 "\", " \
"\"flags\": \"" $4 "\", " \
"\"mask\": \"" $5 "\" }, " \
} \
END {print "]"}' \
| /bin/sed 'N;$s/},/}/;P;D')
if [ -z "$result" ]; then echo {}
else echo $result
fi