【发布时间】:2021-02-17 21:23:19
【问题描述】:
我在文件中有以下数据
They used to carry lots of treats
but now they don’t have any sweets.
And so, if you’re in need of candy,
please don’t visit Mrs. Mandy. He is working in office.But will be late from office
例如:
使用以下命令,我得到了作为同一行中的两个关键字的行
grep "Mandy" file.txt | grep "office"
上面的命令作为输出给我下面一行
please don’t visit Mrs. Mandy. He is working in office.But will be late from office
现在从我得到的输出需要删除第二个出现的关键字:office 并在输出下方打印
预期输出:
please don’t visit Mrs. Mandy. He is working in office.But will be late from
如何实现上述预期输出?
【问题讨论】: