if [[ -z $(screen -list |grep tached) ]];then screen -dRU terminal;elif [[ -n $(screen -list |grep Detached) ]];then screen -dRU $(screen -list|grep Detached|tail -1|awk -F " " '{print $1}'|awk -F "." '{print $2}');else screen -dRU $(screen -list|grep -m 1 Attached|awk -F " " '{print $1}'|awk -F "." '{print $2}')-1;fi 说明: 1 ,没有,创建新的 2 ,有死,链接死的 3 ,否则,链接活着的-1