#!/bin/sh for arg in "$@" do case "$arg" in status) status=1 ;; esac shift done _ifconfig() { [ -z "$_ifdata" ] \ && _ifdata="$(ifconfig)" echo "$_ifdata" } _interfaces="$(_ifconfig | egrep "^[a-z]" | cut -d: -f1 | egrep -v "lo0|enc0|pflog0" | xargs)" if [ -n "$status" ] then for _dev in $_interfaces do # something with awk done fi