Use tee to direct it straight to screen instead of stdout
$ var=$(echo hi | tee /dev/tty)
hi
$ echo $var
hi
More Related Contents:
- How to redirect and append both standard output and standard error to a file with Bash
- How can I pipe stderr, and not stdout?
- Redirect stderr and stdout in Bash [duplicate]
- Bash script – store stderr in a variable [duplicate]
- How to redirect both stdout and stderr to a file [duplicate]
- Shell redirection i/o order
- Piping both stdout and stderr in bash?
- Capture both stdout and stderr in Bash [duplicate]
- How to pipe stdout while keeping it on screen ? (and not to a output file)
- How do file descriptors work?
- Use GNU find to show only the leaf directories
- Make Bash handle variables like Batch
- Some troubles with using sed and awk [closed]
- Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]
- Add a new element to an array without specifying the index in Bash
- Lookup shell variables by name, indirectly [duplicate]
- How to assign a heredoc value to a variable in Bash?
- How do I use su to execute the rest of the bash script as that user?
- How to iterate over associative arrays in Bash
- How to process each output line in a loop?
- How to extract one column of a csv file
- bash: force exec’d process to have unbuffered stdout
- Find and replace filename recursively in a directory
- How can bash script do the equivalent of Ctrl-C to a background task?
- What does it mean in shell when we put a command inside dollar sign and parentheses: $(command)
- How does bash tab completion work?
- How to add leading zeros for for-loop in shell? [duplicate]
- Bash script store command output into variable
- How to use > in an xargs command?
- Subtract two variables in Bash