I have a linux based command named as x2goterminate-session followed by username
e.g
x2goterminate-session john
But there are numerous user sessions that I want to terminate in a single go.
slpusrs=`x2golistsessions_root | grep '|S|' | cut -d "|" -f 2`
Above variable slpusrs finds the list of sleeping users and stores them in the slpusrs variable.
Now I want to execute x2goterminate-session command one by one on the list of users, so that all sleeping users are terminated in a single go instead of typing the command followed by user one by one.
command=x2goterminate-session
for i in "${slpusrs[@]}"; do
"$command" "$i"
done
But It isnt working. Please help
x2goterminate-session bill john steve sue?slpusrsas array, but you set it as scalar. To set an array variable, you needslpusrs=( $(....) )