Search code examples
bashmacoscommand-linegnu-screen

How to send a Return key in an already existing screen session on MacOS?


First, I create a session by typing screen -S test1, then I detach and type screen -S test1 -p 0 -X stuff "ls^M". This doesn't work, it just prints the characters "ls^M" in my session.


Solution

  • Without more details I don't know why it does not work for you but you can try other ways:

    screen -S session -X -p 0 stuff  "echo hello\r"
    # OR 
    screen -S session -X -p 0 stuff $'echo world\r'