0

I want to write a shell script to check if the first param is empty or contains the string "task". I tried:

if [ -z "$*" ] || [$1 != *"task"*] ; then
    echo "Empty or not contains task"
else
    echo "Contains task"

But it is not correct. I even tried to break down the condition:

if [ -z "$*" ] ; then
    echo "empty"
elif [$1 != *"task"*] ; then
    echo "Not contains task"
else
    echo "Contains task"

The empty condition is correct but the condition check on contains string not correct. Anyone knows how to fix it?

Thanks

1 Answer 1

1

Enjoy

if [[ -z "$*" || $1 != "task" ]] ; then
  echo "Empty or not contains task"
else
  echo "Contains task"
fi
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.