Bruno
Bruno

Reputation: 153

How to open a new terminal and run two linux commands?

I have create a .sh script, with option to open terminal and that same terminal run 2 commands. I know to open a new window or tab and run a command but when I put && I receive error like this by using this command:

Commands:

gnome-terminal --tab -- "ls && clear"

Error:

There was an error creating the child process for this terminal
Failed to execute child process “ls && clear” (No such file or directory)

My OS is Linux(Ubuntu)

Upvotes: 2

Views: 5015

Answers (1)

wjandrea
wjandrea

Reputation: 33145

gnome-terminal is expecting a command name. It looks for a command literally called ls && clear but can't find it. You need to run it in a shell:

gnome-terminal --tab -- bash -c "ls && clear"

Upvotes: 3

Related Questions