由于错误,我有多个同名的屏幕会话。如何在不影响其他屏幕会话的情况下,用一个命令删除所有这些会话?
我使用了这篇文章中的命令: https://stackoverflow.com/questions/1509677/kill-detached-screen-session
但是它只打印出会话并且不会删除它们:
我该怎么做才能一次性删除这些会话而不影响其他会话?
谢谢
答案1
这是我用来关闭所有名为 my_screens_to_kill_named_the_same 的屏幕的方法:
# Checking if there are some screen named
if screen -list | grep -q "my_screens_to_kill_named_the_same"; then
# Get the list of id of screens named
ids_to_kill="$(screen -ls | awk '/\.my_screens_to_kill_named_the_same\t/' | awk '{print strtonum($1)}')"
# Loop on that list and kill all the screens named
for id_to_kill in ${ids_to_kill}
do
screen -X -S "$id_to_kill" quit
done
fi