#!/bin/bash for env in a b c; do # 构造screen会话名 screen_name="screen_$env" # 使用-S参数直接停止指定会话 screen -S $screen_name -X quit # 或者使用PID停止 # screen_pid=$(screen -list | grep $screen_name | awk '{print $1}') # kill $screen_pid done