Ubuntu – Running a command in screen daemon mode

bashscreensed

I am trying to run a command in screen mode using the command

screen -dmS screen_name sed -i 's/a/b/'g some-file.txt

Nothing happens. When I put the same command in a script and run the command:

screen -dmS screen_name bash -c /path/to/script

It works.
My question is, can I run a command in daemon mode without first having to put it in a script?
Basically, I need this daemon feature because it helps in running several commands in parallel, by running several sed commands on large files in parallel by throwing each command on a separate screen daemon, which terminates automatically after the program finishes.
Thanks

Best Answer

I guess the issue is with the -S if you try to omit the -S option, it should ,work, even without bash -c so try this

screen -dm sed -i 's/a/b/'g some-file.txt

That should work. BTW screen is not updated, you should consider switching to tmux. It can provide you with much more features.

You can install tmux by typing:

sudo apt-get install tmux

So your code should look like:

tmux new-session -d -s foo 'sed -i 's/a/b/'g some-file.txt'

I could test it with

tmux new-session -d -s hello 'top'

if you type

tmux attach -t hello

It will take you to a session with top. Hope that this helps. check

man tmux

for all features and check here for a comprehensive cheat sheet