假设文件 names.txt 中有多个行
my name is Jim your name please
what is good Harry potter
how is he Jhony and me
等等,500余行。
我使用 awk 命令来搜索/仅打印名称,awk "{ print $4; }" names.txt
所有名称均位于每行的第 4 位
以下命令输出
Jim
Harry
Jhony
等等,超过500个名字。
我使用 sed 命令在与模式匹配的每一行之前打印行。list.txt 已经有很多行。假设
hero is always good and have alpha name
jungle is also called forest and beta owner
carrots are sweet have gama solution
sed 命令搜索单词have
并在模式匹配行之前添加行
sed -i "/have/ s/^/oslo good owner="Jim" and too good\n/" list.txt
及其作品,但用相同的名称书写所有行。
我想在 sed 中使用 awk 命令结果,例如要求在 list.txt 文件中输出应该是
olso good owner="Jim" and too good
hero is always good and have alpha name
jungle is also called forest and beta owner
olso good owner="Harry" and too good
carrots are sweet have gama solution
依此类推,直到 list.txt 文件结束。
在 Windows-10 环境命令提示符中工作