bash - I have 3000 text files, with each reporting a time duration at the end. Is there a way in Bash to find what the maximum value was?
问题描述
I have 3000 text files on a linux cluster, each ending in something like
Run Time of 4.533 mins
I am wondering if there was an easy way in Bash scripting to run a loop or something similar on all these files *.txt
and to extract the times and find what the maximum was?
解决方案
Given a file myFile.txt
formatted like this
some
content
goes
here
...
Run Time of 4.533 mins
You can get the time with tail -n1 myFile.txt | cut -f4 -d' '
tail -n1
returns the last line
cut -d' '
cut the columns by white space
-f4
select the forth entry
follow @Mark comment to apply it to your 3000 files
推荐阅读
- python - RuntimeWarning: coroutine 'main' was never awaited error
- c# - C# create class with conditional operator
- c# - 如何理解佳能 EDSDK 错误代码的含义?
- android - 与特定语言的深层链接
- mysql - MySQL - Generalization Specialization - How to update tables, enforce total participation, allow overlapping subclasses?
- ruby-on-rails - Rails 部分验证取决于控制器
- django - 更新 django rest 框架中的字段
- xamarin.forms - 使用普通 USB 网络摄像头模拟手机摄像头时出现问题
- ios - 如何使用 ECDH 加密快速创建 64 字节公钥和 32 字节私钥?
- excel - 如何从列表中获取最高值