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: 
try this; 

```
user@host:/screen -ls 

There are screens on:
        29229558.pts-5.host   (Detached)
        46661728.pts-22.host   (Detached)

user@host:/screen -r 46661728.pts-22.host

```

If you see (attached) as below; 

```
user@host:/screen -ls
There are screens on:
        29229558.pts-5.host   (Detached)
        46661728.pts-22.host   (Atached)

screen -D -r 46661728.pts-22.host

```
You can send a command to a running screen using `screen -X exec`. See the man page for redirection options.

```
screen -X exec ls

```

Alternatively you can send text to a running screen's stdin buffer using `screen -X paste`, as if the user had typed it. This can be a way of running commands inside an interactive shell.

```
screen -X register a "ls\n"
screen -X paste a

```