Q:

can an array be used with and?

Below I have the following
if [[ -n $ip ]] && [[ -n $netmask ]] && [[ -n $gateway ]] && [[ -n $dns ]]; then

If all variable are set then return true, else return false
Is there a better way to do this?

A:

You can go for brevity -- [[ -n $ip ]] is same as [[ $ip ]]. Also, you can put all the variables inside one [[ keyword, the evaluations would happen the same:
if [[ $ip && $netmask && $gateway && $dns ]]; then

