This question already has an answer here:
- sending text input to a detached screen 3 answers
screen there is a
kill command, which kills the current window. This command can be sent even to a detached
screen session by running:
screen -S SessionName -X kill
This works to kill the current window only. To kill any other window, it appears the only way is to first switch to that window and then kill it. The
select command allows switching between windows in a
screen session. Typing the following while attached to a
screen session will select the window named
However, when not attached to the session, it appears the
select command has no effect. Running the following two commands will kill the current window, rather than the window named
foo (unless of course that is the active window).
screen -S SessionName -X select foo screen -S SessionName -X kill
I have verified that this occurs even if I attach and detach from the session before attempting to select a window (a known workaround for some other screen quirks).