1

I am writing bash script and inside I am executing a command. I want to save the output of the command to variable but also want to print the output of the command to the standard output. I dont want to print the variable once the command is completed. How can I achieve this ?

hYk
  • 764
  • 1
  • 8
  • 21

1 Answers1

1

Try the following, it will print the output of your command and assign to variable.

VAR="$(your_command| tee /dev/tty)"

Ardit
  • 1,522
  • 17
  • 23