# This works
screen -dm -S test3 -t -c "R"
screen -r test3

# THESE DO NOT WORK
screen -dmS test3 -t -c "sudo su -c \"cd ~rstudio/git; R\" -s /bin/bash rstudio"
screen -r test3
screen -dmS test3 -t -c "cd ~rstudio/git"
screen -r test3

# this somewhat works
screen -dm -R test3 -t -c "bash echo 'hello'; sleep3"
screen -dm -R test3 -t -c "echo 'hello'; sleep3"
screen -dm -R test3 -c "bash echo 'hello'; sleep3"
screen -dm -R test3 -c "echo 'hello'; sleep3"
screen -r test3

screen -dm -S test3 -t -c "echo hello; sleep 7"
screen -r test3

screen -D -R test3 -t -c "echo hello; sleep 7"
screen -r test3


screen -dm -S test3 -t -c "sudo su -c \"cd ~rstudio/git; R\" -s /bin/bash rstudio"
screen -r test3



screen -S demo -X stuff '/home/ubuntu/firstScreen.sh
'
Note that this may be the wrong approach. Are you sure you want to type into whatever is active in that session? To direct the input at a particular window, use

screen -S demo -p 1 -X stuff '/home/ubuntu/firstScreen.sh
'
where 1 is the window number (you can use its title instead).

To start a new window in that session, use the screen command instead. 
(Thats the screen Screen command, not the screen shell command.)

screen -S demo -p 1 -X screen '/home/ubuntu/firstScreen.sh'

ls | grep '^test'
screen -dmS demo
screen -ls
screen -p 'demo' -X stuff 'bash /home/ubuntu/test.sh
'
screen -S demo -p 1 -X stuff 'bash /home/ubuntu/test.sh
'
screen -r demo
ls | grep '^test'


exit