The meanings of && and & are essentially different.
- What is
&& in Bash? In Bash - and in many other programming languages ββ- && means "AND." And in the context of executing a command like this, this means that the elements to the left and right of && must be executed sequentially in this case. - What is
& in Bash? And one & means that previous commands - directly to the left of & - just have to run in the background.
So, looking at your example:
gndlp@ubuntu :~$ test -x examples.desktop && echo $? gndlp@ubuntu :~$ test -x examples.desktop & echo $? [1] 2992 0
The first command - how it is structured - actually returns nothing. But the second command returns [1] 2992 , in which 2992 refers to the process identifier (PID), which runs in the background, and 0 is the output of the first command.
Since the second command just runs test -x examples.desktop in the background, this happens pretty quickly, so the process ID is generated and immediately disappears.
source share