When I execute screen -ls
, I see the following. How can I kill all the detached sessions?
There are screens on:
84918.tty
Combining Edward Newell's and Rose Perrone's solutions into a more readable and "screen" like solution.
Add below to your .bashrc
or .bash_profile
.
# function for killing all detached screen sessions
killds() {
detached_sessions=$(screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}')
for s in ${detached_sessions}
do
screen -S "${s}" -X quit;
done
}