由於錯誤,我有多個同名的螢幕會話。如何透過 1 個命令刪除所有這些內容而不影響其他螢幕會話?
我使用了這篇文章中的指令: 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