LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Other *NIX (https://www.linuxquestions.org/questions/other-%2Anix-55/)
-   -   How can I run a command on another shell without changing the current shell? (https://www.linuxquestions.org/questions/other-%2Anix-55/how-can-i-run-a-command-on-another-shell-without-changing-the-current-shell-794580/)

quanba 03-10-2010 09:35 PM

How can I run a command on another shell without changing the current shell?
 
Hi there, I have a problem:

My current shell is: /bin/bash, I just want to run a set of commands on /bin/sh shell without changing the current shell or put the set of commands into a script file.

e.g:
# sh (echo "abc"; echo "cde")

Thanks for your help.

blacky_5251 03-10-2010 10:58 PM

Code:

sh -c "/bin/echo Hello; echo Bye"

quanba 04-05-2010 09:58 AM

thanks

gumaheru 04-05-2010 12:19 PM

blacky_5251 that is definitely correct. But there is one thing here that is missing that is really bad for all of the people that are starting to use linux and just find this answer. They don't understand why that works. To make a long story short the linux community is just coming down to a bunch of people that do things only because they find the exact answer on the internet and never understand anything about it. Quanba, to run a command in another shell you need to specific the shell that you want to run in and follow it with the command that you are going to run. The "-c" argument means that there are commands to run in this shell. This is the same for all shells.


All times are GMT -5. The time now is 07:47 PM.