Shell Goodies: Fetching NIC Interfaces with carrier without SED/AWK
As I'm rewriting some parts of the dhcp boot mechanism of live-boot, I needed the possibiility to fetch network interfaces, without the use of SED/AWK or whatever could help to parse the "ip -oneline link show" output.
As we somehow don't have sed or awk in our initramfs tools, I scribbled this:
for device in /sys/class/net/* ; do
if [ -f "$device/carrier" ]; then
carrier=$(cat "$device/carrier" 2> /dev/null)
if [ "$carrier" = "1" ]; then
if [ "$devicename" != "lo" ]; then
echo "$carrier of $devicename ($interface) is up"