html tool

2018年7月12日星期四

转:重定向 Bash “time” 命令的输出



参考:
https://blog.csdn.net/qianlong4526888/article/details/8848086
https://blog.csdn.net/seizeF/article/details/5164405


了解原理以后,我们可以试图获取time的输出。有两种方法:
一是捕获代码块的输出:
{ time command; } 2 > file.txt (注于bash代码块大括号前后需要一个空格)
另一种方法是捕获子shell进程输出:
(time command) 2> file.txt
这个问题很有意思。

没有评论:

发表评论