-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, Aug 16, 2017 at 04:58:24AM -0400, Gene Heskett wrote: > On Wednesday 16 August 2017 03:28:43 Clive Standbridge wrote: > > > oldIFS="$IFS"; IFS=': '; ip -o link | while read num interface other; > > do declare -p interface; done; IFS="$oldIFS" > > Now thats an interesting bit of bashism, and deeper into it than I have > waded. But for this local network, I know what they are so I can't think > of a situation that would make me use it. But it may well be useful in > the future, so the message is marked to protect it from the expiry > rules.
Nice idiomatic little script. Changing the input field separator (IFS) to parse lines is actually a shell classic and should work on most shells (I just tested with dash), The "declare", OTOH, is pretty Bashist. But it can be replaced by a simple "echo": This should be more portable (at least across the Bourne family): oldIFS="$IFS"; IFS=': '; ip -o link | while read num interface other; do echo "$interface"; done; IFS="$oldIFS" Cheers - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlmUFy4ACgkQBcgs9XrR2kaO0gCePvWrmGWeOv8KNGjLrrI2o2GO cZ4An1lJ/2IVkGKF4Gc/nfyVa/0vV75M =nic4 -----END PGP SIGNATURE-----