I am using shell
trying to capture list of background jobs:
sleep 11 | tee log_1.txt &
sleep 12 | tee log_2.txt &
jobs -p # this returns PIDs
X=$(jobs -p)
echo ${X}
Then I start it like this: sh ./script.sh
But for some reason I get nothing.
Trying to debug it I see that jobs -p
actually returns the list of items.
Something like X=$(ls -al)
also works as expected and the content is captured.