I googled many solutions but did not find one that fully worked. My own rough working is:
[ $(which curl) -eq "" ] || sudo apt install curl
This doesn't quite work, saying "unary operator expected". I've tried =
or ==
, so I'm not getting how to do a test like this. Is it possible that the empty output from which curl
is a $null and I have to test for that?
Alternatively, is there a way to just run sudo apt install curl
and then 2>&null
at the end to suppress if it's already installed?