Raspberry Pi_Eng_10.6.1 “&&” Command – Execute Command by “and” Method


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


10.6   Commands Related to Selective Execution

 

Normally, when a command is processed normally, the exit status is set to zero, which is treated as "True". On the other hand, if the command is not processed normally, the exit status is set to a non-zero value, which is treated as "False".

 

10.6.1  "&&" Command - Execute Command by "and" Method

 

This command processes the next command if the first command is processed normally, and sets the exit status by "and" operation according to the final processing result of the both commands.

 

[Command Format]

< command-1>    &&    < command-2>

 

[Detail Description]

command-1

command-2

Exit status

exec.

result

True/False

exec.

result

True/False

operat.

final

Yes

Ok

True

Yes

Ok/Error

True/False

and

True/False

Yes

Error

False

No

-

-

and

False

 

Command-2 is executed if the processing of the command-1 is "True", and Command-2 is not executed when the processing of the command-1 is "False".

The exit status is set to "True" if the exit status of both <command-1> and <command-2> is "True", or set to "False".