0

I have a bash script that I am modifying. The script now also executes a binary. Say something like this mybin arg1 arg1 The binary takes about 5 minutes to execute and when I execute it from bash directly, it does show the intermediate outputs. When I add it to my script as

`mybin arg1 arg1`

I get the output in the end and bash thinks the output is a command and tries to execute it. So I want to solve 2 things

  1. Show the intermediate output on the screen when I execute the binary from the bash script.
  2. And the output must not be treated to be a command for processing, just regular output
2
  • 1
    Also note $(...) for command substitution serves the same purpose as backticks but is more readable. (oldengineer)--> Commented Aug 11, 2018 at 1:30
  • You may find ShellCheck useful. It automatically points out this issue. Commented Aug 11, 2018 at 3:09

1 Answer 1

2

Remove the backticks.

`prog` means "collect the output of prog and interpolate it into the current command", so if `prog` is the only thing on the command line, its output will be executed as another command. This is known as command substitution.

In other words, the two things you don't want to happen are exactly what ` ` is designed to do.

Sign up to request clarification or add additional context in comments.

1 Comment

@curiousengineer I'm curious: Why did you think you needed the backticks in the first place? A shell script contains commands just like you'd normally type them.

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.