Question: I want to write a bash script to re-attach to the existing linux screen, perform some commands and then detach from that screen. I know to create a new linux screen in detached mode and perform some commands. But I haven't found a way to re-attach to a existing linux screen.

Answer: 
You can give a name to a screen session by using the -S option.
Example : `screen -dS NAME <command>`

Then you can reattach to that session using `screen -r NAME`
To re-attach to the screen you have to follow this steps:

Before de-attaching from the screen, execute:

```
STDOUTTERM=$(who -m|awk '{print $2}')

```

Then you can attach stdout to whatever you want. When you finish, to reattach to stdout, execute this:

```
exec > /dev/$STDOUTTERM

```