0
I'm running DHCP server on local network which calls this script every few seconds:
dumpleases | awk '{print $2}' > leasesnow #get list of all IPs leased in a file, one per line
ADDED=`awk 'NR==FNR{a[$1]=$2;next} !($1 in a) { print $2 }' leasesthen leasesnow` #try to extract only new leases to variable
print $ADDED
checkin.sh $ADDED #do something with new devices on network
cp -f leasesnow leasesthen
I've also tried using diff, but it looks even more complex than awk, because it requires to filter out changed lines from output first.
What's wrong: $ADDED never receives correct (even any) values, which means awk is not working as intended. Can you please explain what's wrong? I'm quite new to awk. Thanks.