JRodDynamite
JRodDynamite

Reputation: 12613

Display output of command executed in bash as it is executing

I've got a line in my bash script like this:

echo "`some_command`"

Now, some_command executes for around 1-2mins and it keeps printing alerts/messages in that interval.

Problem is when I execute my bash script, the script has no output for 1-2mins and then directly displays the output after complete execution of some_command.

How can I make my bash script output some_command as it is executing? Is there a way to do so?

Upvotes: 0

Views: 170

Answers (1)

chepner
chepner

Reputation: 530843

The command substitution is capturing everything your command writes to standard output, then displayed all at once by the echo command. Just run the command by itself. (And when you do want a command substitution, use $(...) instead of backticks.)

some_command  # not echo "$(some_command)"

Upvotes: 4

Related Questions