Currently I am having extreme difficulties when putting the output of a command into a variable. I just have no idea what I am doing wrong.
#! /bin/bash
on = $(nmcli networking connectivity)
echo "$on"
if [ "$on" = "full" ]
then
nmcli networking off
else
nmcli networking on
fi
edit: when I run this file I get nothing from the echo so I am assuming it is something going wrong with the outputing of the on variable.
on=$(nmcli networking connectivity)
When creating and initializing variables, you don't have to put spaces before and after the "equal" sign.
if [ "$on" = "full" ]
The equal comparison on strings must be written with double equals: ==
Also be aware that your output can depend on system language! Check this for cross-language support: HERE