[bash] redirect all subsequent std output to file
I have got a script with an outer and inner loop. The inner loop issues loads of echo's which need to be redirected to a log file determined by the outer loop.
The obvious solution is to redirect every echo to >$LOG and set LOG in the outer loop. Code:
for f in $FILES ; do |
If memory serves me you want to do something like this:
Code:
# redirect stdout to file descriptor http://www.linuxtopia.org/online_boo...ripting_guide/ Check out chapter 16 "I/O Redirection", sub chapter 16.1 "Using exec". That has better details and more in-depth instruction than I can provide from memory. Edit: I'd also suggest redirecting stderr or you might miss some messages from applications in your loop |
Code:
for file in "${files[@]}" ; do |
An answer to something I didn't think there was an answer to in under fifteen minutes - amazing!
How can you redirect stderr to the same file as stdout using the exec method? |
Note:
Code:
exec 6>&1 Code:
exec 6>&1 |
All times are GMT -5. The time now is 06:31 AM. |