ifconfigvar=$(ifconfig eth0) && echo $ifconfigvar You can see that output of the above command has no formatting:
eth0 Link encap:Ethernet HWaddr 00:1f:16:ef:5b:c0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
echo "$ifconfigvar". See shell parameter expansion.ifconfigis effectively abandonware, and has not been maintained on Linux for over a decade. You should really, really be using iproute2 (theipcommand, as inip addr listorip link list) instead. Some content added in modern kernels but not supported in decade-old onesifconfigdoesn't know how to print at all and will just silently ignore (anonymous secondary addresses, for instance).