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.txtNothing happens. When I put the same command in a script and run the command:
screen -dmS screen_name bash -c /path/to/scriptIt 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
2 Answers
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.txtThat 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 tmuxSo 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 helloIt will take you to a session with top. Hope that this helps. check
man tmuxfor all features and check here for a comprehensive cheat sheet
1Does this work for you?
screen -dmS screen_name bash -c "sed -i 's/a/b/'g some-file.txt" 7