Bash/sh - difference between && and ;

前端 未结 7 811
轮回少年
轮回少年 2020-12-07 11:22

I normally use ; to combine more than one command in a line, but some people prefer &&. Is there any difference? For example, cd ~; c

相关标签:
7条回答
  • 2020-12-07 12:13

    Commands separate by ; are executed sequentially regardless of their completion status.

    With &&, the second command is executed only if the first completes successfully (returns exit status of 0).

    This is covered in the bash manpage under Lists. I would expect any Unix-like shell to support both of these operators, but I don't know specifically about the Android shell.

    0 讨论(0)
提交回复
热议问题