【发布时间】:2013-08-07 05:15:45
【问题描述】:
就像我们将输出从 for 循环块重定向到文件
for ()
do
//do something
//print logs
done >> output file
在 shell 脚本中类似,有没有办法将功能块的输出重定向到文件,像这样?
function initialize {
//do something
//print something
} >> output file
//call initialize
如果没有,还有其他方法可以实现吗?请注意我的函数有很多消息要打印在日志中。在每一行将输出重定向到文件会导致大量的 I/O 利用率。
【问题讨论】: