【发布时间】:2020-10-05 03:36:49
【问题描述】:
我需要在 Linux 上搜索这些关键字
- 渲染完成
- 在 处渲染图像
- CPU @
包含在一个包含多个 .txt 文件的文件夹中。
使用grep 我获得了以下 3 个不同行中列出的输出
1 x Intel(R) Core(TM) i9-7920X CPU @ 2.90GHz (12 cores, 24 logical) with 63929MB
rendering image at 640 x 480, 1 AA sample
render done in 1:17.135
我现在需要的是使用相同的关键字(render done inrendering image atCPU @)将其拆分,以便输出看起来像
render done in1:17.135
rendering image at640 x 480
CPU @2.90GHz
在实践中,我需要通过其描述分隔值,因此 in 可以轻松指向它并进行进一步计算(在 excel 或类似中)。 如果输出是 .xls 或 .csv 文件,那么如果这些字段包含在不同的单元格中,那就太好了。
我目前正在使用这个命令
grep -E -r 'render done in|rendering image at|CPU @' /home/ciara/Documents/Logs/ > /home/ciara/Documents/output.txt
我尝试与cut 或awk 分开,但没有成功。
有什么帮助吗?
【问题讨论】: