Using nohup within a loop of a bash script Using nohup within a loop of a bash script shell shell

Using nohup within a loop of a bash script


Problem is here:

for d in $dList; do

That will only run for loop once for the 1st element of the array.

To iterate over an array use:

for d in ${dList[@]}; do

Full working script:

dList=("dname1" "dname2" "dname3")for d in "${dList[@]}"; do   cd "$d"  { nohup echo "$d" & cd -; } 2>/dev/nulldone