Print the cause if the status is failed LAB -CONDITIONAL- LOGIC Q.1


showing this error
line 17: [: too many arguments
how to solve that error

to check where am i going wrong , lastly i copied the script and pasted it
showing this error !

If the variable $rocket_status contains wither nothing at all or multiple words, then the expansion in [ $rocket_status = "failed" ] will not make sense to bash

You should put the variable in quotes too

if [ "$rocket_status" = "failed" ]

but in video no quotes are used ?

That may be so in which case the video should get fixed.
This is about the way shell script actually works.

Shell expands all variables first, then looks at the rest of the statement.

Given

if [ $rocket_status = "failed" ]
  • If $rocket_status variable was empty, then bash would try to evaluate the following
    if [  = "failed" ]
    
    which is an error.
  • If $rocket_status variable contained rocket is fine, then bash would try to evaluate the following
    if [ rocket is fine = "failed" ]
    
    which is also an error - in this case “too many arguments”, as 3 are expected but 5 are present,

Looking at both cases again, but with the variable enclosed in quotes, they would look like

  • if [ "" = "failed" ]
  • if [ "rocket is fine" = "failed" ]

This time both have the expected 3 arguments.