#!/bin/sh ### DEFAULTS ### ARGUMENTS for arg in "$@" do case "$arg" in start) _start=1 ;; stop) _stop=1 ;; status) _status=1 ;; route) _route=1 ;; wifi) _wifi=1 ;; hotspot) _hotspot=1 ;; adhoc) _adhoc=1 ;; esac shift done ### FUNCTIONS _ifconfig() { [ -z "$_ifdata" ] \ && _ifdata="$(ifconfig)" echo "$_ifdata" } ### DATA _interfaces="$(_ifconfig | egrep "^[a-z]" | cut -d: -f1 | egrep -v "lo0|enc0|pflog0" | xargs)" ### MAIN PROGRAM if [ -n "$_status" ] then for _dev in $_interfaces do # something with awk done fi