bash script for cycling through all screen -ls

Jon Bendtsen <[email protected]> Fri, 28 Jul 2006 14:25:53 +0200
Newsgroups gmane.comp.gnu.screen
Message-ID <D8F02331-7D1B-47E5-85CF-472A25E44922__32140.0081775666$1238088951$gmane$org@diku.dk>
Hi

I got tired of having to type alot or cut'n'paste all the screens  
listed using
	screen -ls
So i made a small bash script that does that semiautomaticaly.

It parses the output from screen -ls and attaches to each screen one
by one. To get to the next one just deatach using normal C-a d

Just before entering the screen session, it tells you which command that
screen session is running. 2 seconds later the script enters the screen
session. It is safe to press ctrl+c at this moment since i use a  
sleep 2.

After using it for some time i figured that i got rid of all the bugs  
and that
others might like it. I call it allscreens and the script is naturaly  
under the
same GPL as screen is.

#!/bin/bash

for window in $(screen -list | grep "(.*)" | cut -d"." -f1 | sed -e  
"s/\t//g"); do
   childpid=$(pstree -p -A $window | sed -e "s/.*---//" | sed -e "s/.* 
(//" | sed "s/)$//")
   childtxt=$(ps $childpid | cut -b 28-)
   echo $childtxt
   sleep 2
   screen -r $window
done