Question about linux command

What the two ampersands do in the following command:

(make foo&)&
+3
source share
3 answers

(and )execute the command in the subshell. This means that a separate shell is generated and the command is launched. This is probably due to the fact that they wanted to use the operation with the shell (phoning - other examples - redirection, etc.). The first command &in the background command runs the command in a subshell (i.e. make foo). The second ampersand uses the subshell itself to immediately return the command line.

Here you can see the effects.

Foreground on the current shell

(bb-python2.6)noufal@NibrahimT61% ls # shell waits for process to complete
a  b  c  d  e

Background of current shell

(bb-python2.6)noufal@NibrahimT61% ls& #Shell returns immediately.
[1] 3801
a  b  c  d  e
[1]  + done       /bin/ls -h -p --color=auto -X

Using a subshell (Foreground)

(bb-python2.6)noufal@NibrahimT61% (ls&) # Current shell waits for subshell to finish.
a  b  c  d  e                           

, .

(BAckground)

(bb-python2.6)-130- noufal@NibrahimT61% (ls &)&
[1] 3829
a  b  c  d  e
[1]  + exit 130   (; /bin/ls -h -p --color=auto -X &; )

( , ls). , .


. , "shell" (, , , , ..), ( (, )), -c , bash. exec , - . , , . ( ) . ", ".

+3

, , . , Makefile . , .

+1

Ampersand is used as a line continuation character in makefiles.

It’s hard to say for sure, because there is not enough context in your question.

0
source

Source: https://habr.com/ru/post/1729366/


All Articles