[root@localhost tmppcm]# ls ; echo exit code was: $? & echo pid is: $!test.txt.................lastfile.txt[1] 1265pid is: 1265exit code was: 0In above it is as it runs ls to begin with, and then ends by running the echo's in 'parallel'.Not quite what I want. I'd like that the sequence ls and echo exit code was: $? to be performed in the background, and echo process id in 'parallel'.A solution could be to use || instead of ; between ls and echo exit code was:[root@localhost tmppcm]# ls || echo exit code was: $? & echo pid is: $![1] 1271pid is: 1271test.txt.................lastfile.txtexit code was: 0Is there a more clever way to do this with the A ; B & C combination that I'm missing?
shell: combine semicolon and ampersand in bash/sh
bash;shell