Linux 中 如何将time命令输出的时间信息保存在文件中

 

001、 通常做法

复制代码
[root@localhost test]# time seq 10 > a.txt 2> xxx     ## 完全追加至xxx

real    0m0.002s
user    0m0.000s
sys     0m0.002s
[root@localhost test]# ls
a.txt  xxx
[root@localhost test]# cat a.txt
1
2
3
4
5
6
7
8
9
10
[root@localhost test]# cat xxx    ## 无内容
复制代码

 

002、正确做法

复制代码
[root@localhost test]# ls
[root@localhost test]# time (seq 10 > a.txt) 2> xxx     ## time作用命令用括号括起来,后边在重定向
[root@localhost test]# ls
a.txt  xxx
[root@localhost test]# cat a.txt
1
2
3
4
5
6
7
8
9
10
[root@localhost test]# cat xxx

real    0m0.001s
user    0m0.000s
sys     0m0.001s
复制代码

 。

下边也可以:

 。

 

posted @   小鲨鱼2018  阅读(19)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-01-27 西数硬盘颜色
2021-01-27 bash: javac: command not found...
点击右上角即可分享
微信分享提示