'&&' vs. '&' with the 'test' command in Bash

后端 未结 3 756
面向向阳花
面向向阳花 2020-11-29 06:40

Consider:

gndlp@ubuntu:~$ test -x examples.desktop  && echo $?
gndlp@ubuntu:~$ test -x examples.desktop  & echo $?
[1] 2992
0

W

3条回答
  •  日久生厌
    2020-11-29 07:04

    Look at what your commands are:

    test -x examples.desktop  && echo $?
    

    This means check to see if examples.desktop is executable and if it is then execute echo $?.

    test -x examples.desktop  & echo $?
    

    means check to see if examples.desktop is executable and start running it in the "background". Then execute echo $?.

提交回复
热议问题