小编joe*_*joe的帖子

awk操纵多个文件

我有以下文件file1和file2(作为示例)

$cat file1.txt
SERVICE: 1
TASK: 1
RESULT: 1
ADDITIONAL: 1

SERVICE: 2
TASK: 2
RESULT: 2
ADDITIONAL: 2

SERVICE: 3
TASK: 3
RESULT: 3
ADDITIONAL: 3
Run Code Online (Sandbox Code Playgroud)

$cat file2.txt
SERVICE: 1
TASK: 1
RESULT: 1
ADDITIONAL: 1

SERVICE: 2
TASK: 2
RESULT: 2
ADDITIONAL: 2

SERVICE: 3
TASK: 3
RESULT: 3
ADDITIONAL: 3
Run Code Online (Sandbox Code Playgroud)

我需要以下输出:

文件的名称和每个块在SERVICE上循环:在下面的1行中用管道"|"分开

file1.txt | SERVICE: 1 | TASK: 1 | RESULT: 1 | ADDITIONAL: 1
file1.txt | SERVICE: 2 | TASK: 2 | RESULT: 2 | ADDITIONAL: …
Run Code Online (Sandbox Code Playgroud)

awk filenames line output

0
推荐指数
1
解决办法
120
查看次数

标签 统计

awk ×1

filenames ×1

line ×1

output ×1