Checking if a Screen of the Specified Name Exists

You can grep the output of screen -list for the name of the session you are checking for:

if ! screen -list | grep -q "myscreen"; then
    # run bash script
fi

You can query the screen 'select' command for a particular session; the shell result is '0' if the session exists, and '1' if the named screen session is not found:


$ screen -S Tomcat
$ screen -S Tomcat -Q select . ; echo $?
0

versus:


$ screen -S Jetty -Q select . ; echo $?
No screen session found.
1

Note that the '.' after the select is optional, but may be more robust.