2

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)

1
  • What's the point of ls && clear which only runs clear if ls fails. How could ls fail? Why clear the screen of your results as soon as you generate them? Commented Jun 4, 2019 at 17:47

1 Answer 1

3

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"
Sign up to request clarification or add additional context in comments.

5 Comments

-x is deprecated in favor of --.
@GonzaloMatheu The Ubuntu manpage doesn't mention --. (I just added a link to the manpage for 18.04.) I'm not at my machine ATM so can't check, but -x still works, right?
Yes, it works. But it show the following message: ``` # Option “-x” is deprecated and might be removed in a later version of gnome-terminal. # Use “-- ” to terminate the options and put the command line to execute after it. ```
On gnome-terminal version GNOME Terminal 3.28.2 using VTE 0.52.2 +GNUTLS -PCRE2
@Gonzalo Huh, I couldn't find any documentation about the deprecation, but a lot of other questions on SE that mention it. So I updated the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.