I am trying to check if multiple command line arguments are set. Eg.
if [-n "$1"] && [-n "$2"] && [-n "$3"]; then
do something
else
do something else
fi
But I keep getting
bash: [-n: command not found
What's the correct way to do this?
You need spaces between the braces, i.e.
if [ -n "$1" ] && [ -n "$2" ] && [ -n "$3" ]; then
You can also use extended test command ([[...]]) as
if [[ -n "$1" && -n "$2" && -n "$3" ]]; then