Get interface names

I remember something on Stack Overflow or one of the other similar technical help forums that showed a way to get all the interface names on a particular computer. I could not find the reference and my attempts to recall it from memory were not successful, so I wrote the following command line that seems to do the trick:

for i in $(ip -o link show | cut -d: -f2 | xargs); do if [[ $i != "lo" ]]; then echo $i; fi; done

Explanation: use the ip command using the “one line” option to list all the network interfaces. They will be the second field on each line of the resulting output. The xargs command will trim leading and trailing spaces from the interface name. Filter out the loopback interface “lo” and then echo each entry.