Kill screen session using command line & bash

To kill an active screen, use the following command:

$ screen -S myscreen -X quit

To use this in a bash script, use the following:

# Kill screen if running
if [ $(screen -list | grep "$sessionname" | wc --lines) -ge 1 ]; then
    echo "screen session $sessionname is running"
    screen -S "$sessionname" -X "quit"
If you liked this posting, please feel free to leave me a comment below.
View this page on GitHub.
Posted .


Leave a Reply