I'm not sure if it is possible but what I want to do is to run a bash command and storing the output in a variable AND display it as if I launched the command normally. Here is my code:
VAR=`svn checkout $URL`
So I want to store the output in VAR and still see the result (and because svn checkout takes a long time, I can't do echo $VAR just after..)
Thanks
Variables are an essential feature of bash programming in which we assign a label or name to refer to other quantities: such as an arithmetic command or a value. They are used to make the machine programs more readable for humans. Using the echo command you can display the output of a variable or line of text.
The echo command writes text to standard output (stdout). The syntax of using the echo command is pretty straightforward: echo [OPTIONS] STRING... Some common usages of the echo command are piping shell variable to other commands, writing text to stdout in a shell script, and redirecting text to a file.
If the command is run from a terminal, you can do:
VAR=$(svn checkout $URL | tee /dev/tty)
You don't have to call the external tee
:
VAR=$(svn checkout $URL) && echo $VAR
or even:
VAR=$(svn checkout $URL); echo $VAR
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With