detecting command not found in bash script

前端 未结 3 555
余生分开走
余生分开走 2020-12-18 09:11

I have a series of command to execute. However I need to exit whenever \'command is not found\' error occurs. So post execution check of output is not an option

The

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 09:38

    If this should be done from a script, it's natural to use a conditional to express this kind of behaviour:

    asdf 2> /dev/null || exit 1
    

提交回复
热议问题