> wooledg:~$ ip -o link | awk -F": " '{print $2}'
> lo
> eth0
> 
> The only other scripting language I know that can do splitting with
> multi-character separators is perl.
> 
> wooledg:~$ ip -o link | perl -ne '@x=split(/: /); print $x[1], "\n"'
> lo
> eth0
> 
> Bash and Tcl can't do it, at least not with their native toolsets.

Bash can, e.g.

$ oldIFS="$IFS"; IFS=': '; ip -o link | while read num interface other; do 
declare -p interface; done; IFS="$oldIFS"
declare -- interface="lo"
declare -- interface="eth0"
declare -- interface="br0"
declare -- interface="vethJWC4DL"


-- 
Cheers,
Clive

Reply via email to