bash - Bash:在循环的每次迭代中将时间的标准错误输出到新文件
问题描述
实际上,我只是想在每次循环运行时将时间的标准错误输出到不同的文件,这是我的代码,我不确定为什么当我有 $i. 这是我目前的代码。
(time for i in {1..5}
do
#some command
done) > temp.txt 2>> $i.txt
下面的代码有效,但每次迭代都没有单独的文件。
(time for i in {1..5}
do
#some command
done) > temp.txt 2>> output.txt
解决方案
您需要将time
命令放在循环内,因为该$i
变量不存在于循环外。
for i in {1..5}
do
time some command 2>>"$i.txt"
done > temp.txt
推荐阅读
- php - 方法 Illuminate\Routing\RouteRegistrar::groub 不存在
- awk - 使用 awk 进行点分隔解析
- laravel - 使用观察者请求验证
- python - How to update requirements?
- javascript - 取消选中复选框后如何从数组中删除元素
- xamarin.ios - Xcode 11 更新后 Xamarin iOS 模拟器黑屏
- sql - 如何在 Asp.net Mvc 中显示没有模型的数据?
- rest - rest - 将用户限制在自己的数据中的方法
- java - 如何在 Spring MVC Web 应用程序中创建会话范围的调度程序?
- python - 如何像在 ggplot 中一样在 matplotlib 中创建堆积条形直方图