我正在尝试了解exec > >(tee logfile)
以下代码中的效果:
#!/bin/bash
exec 7>&1 # save stdout for later reset
exec > >(tee logfile) # point stdout to FIFO pointing to tee command?
#+expect any subsequent output to stdout to be sent
#+both to stdout and logfile.
# so let's send some output
echo
echo howdy # expect these strings to be sent both to terminal and
echo g\'day #+logfile
echo hello!
# restore stdout
exec 1>&7
exec 7>&-
#check content of logfile!
echo ------------ …
Run Code Online (Sandbox Code Playgroud) bash ×1