Comment 10 for bug 1564808

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

A possible solution will be using:
nmcli -f GENERAL -t dev list | tr '\n' ' ' | grep -oP 'TYPE:\Kgsm.*' | sed 's/GENERAL.TYPE:.*//' | grep -oP 'GENERAL.IP-IFACE:\K\S*'

This command will:
1. Get the `nmcli dev list` output in multiline form, with terse output.
    GENERAL.DEVICE:wwan0
    GENERAL.TYPE:gsm
    GENERAL.VENDOR:Dell
2. Replace the newline with `tr`
3. Get the text after the "TYPE:gsm" pattern
4. Get rid off the text after the next "TYPE" pattern, this will guarantee what we get is the gsm sector.
5. Get the interface name with `grep`

Note that `nmcli dev list` is for Precise, for Xenial, we will need to use `nmcli dev show`