Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

linux between subshell variables

One way:

FOO=bar sh -c 'first && second'

FOO=bar BAZ=quux sh -c 'first && second'

Another way to do this is to create the variable and export it inside a subshell. Doing the export inside the subshell ensures that the outer shell does not get the variable in its environment:

( export FOO=bar; first && second )
Source by unix.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #linux #subshell #variables
ADD COMMENT
Topic
Name
4+5 =