I have this code to parse PIDs from lsof output, As you can see echo $PID is working fine here, showing all PIDs, But I would like to append all PIDs to one variable ALL_PIDS, ( and used it then for killing all proces at once. Why is not working ?
this work
# lsof +d /var/log/ | tail -n +2 | awk ' { print $2 }' | uniq| while read PID; do echo $PID; done
940
1181
1603
this not work, I got empty line
# lsof +d /var/log/ | tail -n +2 | awk ' { print $2 }' | uniq| while read PID; do ALL_PIDS+=$PID; done
# echo $ALL_PIDS
#