我希望编写一个简短的bash脚本,它使用awk来调整三个文件的内容,并添加一个额外的行,其中一些文本作为第四行.例如:
档案1:
one.0
one.1
one.2
one.3
Run Code Online (Sandbox Code Playgroud)
文件2:
two.0
two.1
two.2
two.3
Run Code Online (Sandbox Code Playgroud)
档案3:
three.0
three.1
three.2
three.3
Run Code Online (Sandbox Code Playgroud)
期望的结果:
one.0
two.0
three.0
sometext
one.1
two.1
three.1
sometext
one.2
two.2
three.2
sometext
one.3
two.3
three.3
sometext
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
$ cat a
a0
a1
a2
a3
$ cat b
b0
b1
b2
b3
$ cat c
c0
c1
c2
c3
$ paste -d '\n' a b c | awk '1; NR % 3 == 0 {print "some text"}'
a0
b0
c0
some text
a1
b1
c1
some text
a2
b2
c2
some text
a3
b3
c3
some text
Run Code Online (Sandbox Code Playgroud)