使用 AWK 或 SED 添加字符串到列表?

ayr*_*nna 3 sed awk gawk

您好,我希望能够使用 AWK 或 SED 来编辑姓名列表。

输入列表文件示例:

john
paul
rose
lily
Run Code Online (Sandbox Code Playgroud)

期望的输出:

I am john of earth;
I am paul of earth;
I am rose of earth;
I am lily of earth;
Run Code Online (Sandbox Code Playgroud)

我也想要末尾的分号。我不想使用 for 循环的 shell 脚本。

tal*_*zin 5

awk您可以使用print

awk '{ print "I am", $1, "of earth;" }' list
Run Code Online (Sandbox Code Playgroud)

或者printf

awk '{ printf("I am %s of earth;\n", $1); }' list
Run Code Online (Sandbox Code Playgroud)