【发布时间】:2021-10-03 23:08:52
【问题描述】:
我想用多个分隔符grep文件中的多个信息,并显示文件信息,只用一个命令。
./WBL-FILE-S-1-execution79065.html
./WBL-FILE-S-1-execution79066.html
./WBL-FILE-S-1-execution79067.html
如果我这样做:
find . -type f -name « *WBL-FILE* » | xargs grep "Fichier lu"
我的结果如下:
./WBL-FILE-S-1-execution79065.html:<td title="Message">Fichier lu /opt/data/in/bl/000334_iwel1C010116730.blc.TRT</td>
./WBL-FILE-S-1-execution79065.html:<td title="Message">Fichier lu /opt/data/in/bl/000312_iwel1C010116727.blc.TRT</td>
./WBL-FILE-S-1-execution74707.html:<td title="Message">Fichier lu /opt/data/in/bl/000420_iwel1C010116284.blc.TRT</td>
目标是获取文件的日期、文件名、XXXXXX_iwel 编号和 CXXXXXXXXX 编号。
例子:
2021-07-13 13:47 WBL-FILE-S-1-execution79065.html 000334 010116730
2021-07-13 14:48 WBL-FILE-S-1-execution79065.html 000312 010116727
2021-07-14 14:49 WBL-FILE-S-1-execution74707.html 000420 010116284
我几乎成功提取了不同的部分,但之后,我无法获取原始文件的“ls”(日期)信息。
有没有办法只用一行命令组合来做到这一点?
谢谢
【问题讨论】:
-
“一个命令”的概念在 Bash 中没有什么价值,因为您可以通过管道传输几乎所有内容来实现您的目标。例如,在您的命令中涉及 2 个命令:
find和xargs(也可以说grep是另一个命令) -
谢谢我更新了问题;)
-
« *WBL-FILE* »语法无效;你的意思是"*WBL-FILE*"?