Please help to see if there is someway to make below scrip workable?
name='bob'
# below script reports 'bash: !: event not found' error
sh -c "echo $name; sleep 20 & pid1=$!; sleep 10 & pid2=$!; echo \"pid1: $pid1, pid2: $pid2\""
# below script $name will not become bob
sh -c 'echo $name; sleep 20 & pid1=$!; sleep 10 & pid2=$!; echo \"pid1: $pid1, pid2: $pid2\"'
[Add 01/03]
This question is somewhat duplicate of this one, it's my fault that the description of the original question is not clear and accurate enough, and I try to create a new one to make it more specific and clear.