Kill all detached screen sessions

Rose Perrone picture Rose Perrone · Jan 21, 2013 · Viewed 65k times · Source

When I execute screen -ls, I see the following. How can I kill all the detached sessions?

There are screens on:

    84918.ttys002.ros-mbp   (Detached)

    84944.ttys008.ros-mbp   (Detached)

    84970.ttys013.ros-mbp   (Attached)

    84998.ttys002.ros-mbp   (Detached)

    85024.ttys002.ros-mbp   (Detached) 

5 Sockets in /var/folders/86/062qtcyx2rxbnmn8mtpkyghs0r0r_z/T/.screen.

Answer

Milind Shah picture Milind Shah · Jun 20, 2013

screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill

Kill only Detached screen sessions (credit @schatten):

screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill