[Router RT-AX86U_Pro: Running RMerlin 3004.388.7 -- uname -a =(Linux RT-AX86U_Pro 4.19.183 #1 SMP PREEMPT Fri Apr 26 14:23:13 EDT 2024 aarch64 ASUSWRT-Merlin) ]
Sorry but the awk command does not work for me on my Router and the 'nvram get wan_ifname' is *not* blank.
I have tried with GNU gawk as well and get the same result !!!???
I am cutting & pasting your commandline from the post into an 'echo' command to display the result.
(Including your new amended version and it does not work on my router !!!???)
I am confused as you are so sure it works *but* see following screen-capture:
View attachment 58865