Le 31/01/2016 03:12, Steve Litt a écrit :
#!/bin/sh
if test "$#" == "0"; then
   lineno="1"
else
   lineno=$1
fi

ip link | \
   cut -d ' ' -f2 | \
   grep ^w | \
   sed -e "s/:\s*$//" | \
   head -n $lineno | \
   tail -n 1

    Doesn't work out of the box.

If /usr/bin/test was invoqued you should write '-eq' instead of '=='. But shell languages have non-standard built-ins. If /bin/sh points to dash, like in Debian, then the built-in test would accept '='. I guess '==' is a bashism (actually the adoption of a Cism by a shell language). Replacing '==' by '=' just works.

    Thanks for the script nevertheless :-)

    Didier

_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to