One option is to use Add-Content or Set-Content instead of Out-File. The *-Content cmdlets use ASCII encoding by default, and have a -Passthru switch so you can write to the file, and then have the input pass through to the console: Get-Childitem -Name | Set-Content file.txt -Passthru ...

In this case I believe > >(tee -a _testoutput.txt) and | tee -a _testoutput.txt would behave identically. The standard error version of that is obviously necessary since there is no stderr pipe. The other main difference between the pipe version and the Process Substitution (>(...)) version is where the sub-shell...

You can play around with file descriptors like this; ((date | tee >( wc >&3) | wc) 3>&1) | wc or ((command1 | tee >( command2 >&3) | command3) 3>&1) | command4 To explain, that is tee >( wc >&3) will output the original data on stdout, and the inner...

Hard coded solutions tee Echo nothing and simple send it to multiple files using the tee command. Like this: $ echo -n | tee file1 file2 file3 file4 file5 All files in that list will be empty and created if they don't exist. Applied to your answer this would be:...

Change your script to: Command1 | tee >(grep sth || Command2) to achieve the desired result. A word about Subshells >(....) is a subshell. Anything and everything that you do within that subshell (except for the exit status of said subshell) is completely isolated from the outside world: (a=1); echo...

This is not possible to do directly: Each file descriptor is assigned to exactly one resource (typically a file). If you want a write to a FILE yield in writes to multiple files, you have to do some tricks. Here are some ideas: Use the GNU-only function fopencookie(3) to make...

This is a variant of BashFAQ #24. var 2>&1 | tee $LOGV ...like any shell pipeline, has the option to run the function var inside a subprocess -- and, in practice, behaves this way in bash. (The POSIX sh specification leaves the details of which pipeline components, if any, run...

The ERR trap fires for "simple commands" a pipeline is not a simple command. It might fire for the result of the whole pipeline (I'm not sure) and you might be able to get something closer to what you want by setting pipefail. (Note: This is one of the reasons...

The problem is most likely that grep is buffering its output — selecting large chunks of input, filtering them, and outputting the result — so it handles the output of yes smoothly (because yes quickly generates a lot of input for it to filter and output), whereas your ssh command...

You've only created one pipe, yet the command line needs four pipes. That means that the commands after the first are fighting over the output from the first, and basically nothing works sanely. You'll need to create more pipes. You don't have to create them all up front, but you...