I want to get the pids of two background processes,
sleep 20 & pid1=$\\!; sleep 10 & pid2=$\\!; echo \"pid1: $pid1, pid2: $pid2\"
and
Your syntax kindly incorrect, try this:
[root@XXX ~]# sleep 5 & pid1=$!; sleep 6 & pid2=$!; echo "pid1: ${pid1}, pid2: ${pid2}" [1] 2308 [2] 2309 pid1: 2308, pid2: 2309