简体   繁体   中英

How to open new terminal and run a command from the current terminal in Ubuntu?

I was writing the following alias in .bashrc

alias ss='gnome-terminal; echo Starting Server;'

I was intending to run ss on one terminal (T1) and allow echo Starting Server to run on another terminal (T2). Though T2 opens the command gets executed on T1. How to make it run on T2?

You should try this command:

gnome-terminal -- /bin/sh -c 'echo Starting Server; sleep 10'

And if you want keep your terminal open after 10 seconds, you should do:

gnome-terminal -- /bin/sh -c 'echo Starting Server; sleep 10; exec bash'

You can find a similar answer here: https://unix.stackexchange.com/questions/373186/open-gnome-terminal-window-and-execute-2-commands/373188#373188

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM