hexacyanide
hexacyanide

Reputation: 91719

Bash: Killing all screens with a specified name

If I have multiple screens with the same name, how could I kill all of them without checking all of their PIDs, and then executing screen -wipe?

Example:

24754.screen1  (Detached)
32236.screen1  (Detached)
7308.screen1   (Detached)
3896.screen1   (Detached)
10155.screen1  (Detached)
10888.screen1  (Detached)
28438.screen1  (Detached)
26008.screen1  (Detached)

I would like to kill all instances of screen1, terminate any processes running within, and not need to run screen -wipe after.

Upvotes: 2

Views: 1898

Answers (1)

MeaCulpa
MeaCulpa

Reputation: 911

Not sure if clean enough. The -X quit operation shall not need a -wipe:

screen -ls | awk -vFS='\t|[.]' '/screen1/ {system("screen -S "$2" -X quit")}'

You should able to dive into each shell your session started and send an exit in theory

Upvotes: 4

Related Questions