nmcli -t -f STATE,WIFI,WWAN
gives way out
connected:enabled:disabled
which I would like to convert to something like
Networking: connected, Wifi: enabled, WWAN: disabled
The logical solution for me is to turn this into an array. Being a completely new bash script, I read that arrays are just regular variables and the elements are separated by spaces. My code is currently
declare -a NMOUT=$(nmcli -t -f STATE,WIFI,WWAN nm | tr ":" "\n")
which seems to apply to working in a for loop, but not if I want to request a specific item, as in $ {NMOUT []}. Clearly, I'm missing some key concept. How to access certain elements in this array?
dn3s source
share