OK、manページをよく読んでから私は注意します:
-X Send the specified command to a running screen session. You can
use the -d or -r option to tell screen to look only for attached
or detached screen sessions. Note that this command doesn't work
if the session is password protected.
画面セッションを実行しています。言い換えれば、1つのコマンドだけで、あなたが探していることをそのように行うことができるとは思いません。ただし、
- ウィンドウが存在しない場合は作成します
- コマンドをウィンドウに送信します
ウィンドウに接続します。
NL = $'\ n'NAME = foo screen -ls | grep "$ NAME" || screen -d -m -S "$ NAME" screen -r "$ NAME" -X stuff "source file $ NL" screen -D -R -S "$ NAME"
(コマンドの送信からGNU画面への-Xの動作の明確化)