I have this output in the following and I am trying to convert it to JSON api format. I want to know how can I do it.
rock64@rockpro64:~$ sh MACscript.sh
eth0
11:1d:11:11:11:1d
lo
00:00:00:00:00:00
Do I have to use python script or can I do it using shell script?
This is my MACshell script:
rock64@rockpro64:~$ cat MACscript.sh
!/bin/bash
getmacifup.sh: Print active NICs MAC addresses
D='/sys/class/net'
for nic in $( ls $D )
do
echo $nic
if grep -q unknown $D/$nic/operstate
then
echo -n ' '
cat $D/$nic/address
fi
done