【发布时间】:2021-12-07 23:31:44
【问题描述】:
输入文件-test1
Failed ,abc, /clients/FORD_1030PM_EST_Windows2008, Windows File System
Failed ,abc, /clients/FORD_1030PM_EST_Windows2008 ,Windows File System
Completed, abc /clients/FORD_1030PM_EST_Windows2008, Windows File System
Failed ,def ,/clients/FORD_1030PM_EST_Windows2008 ,Windows File System
Failed ,def ,/clients/FORD_1030PM_EST_Windows2008 ,Windows File System
Failed ,def ,/clients/FORD_1030PM_EST_Windows2008 ,Windows File System
Failed ,ghi ,/clients/FORD_1030PM_EST_Windows2008, Windows File System
Failed ,jkl ,/clients/FORD_1030PM_EST_Windows2008 ,Windows File System
Completed ,def ,/clients/FORD_1030PM_EST_Windows2008, Windows File System
Completed ,hkm ,/clients/FORD_1030PM_EST_Windows2008 Windows File System
预期输出
Failed ghi, /clients/FORD_1030PM_EST_Windows2008, Windows File System
Failed jkl, /clients/FORD_1030PM_EST_Windows2008, Windows File System
代码
sed -n '/Completed/ s,\(.*\) .* Completed$,\1,a' "$pwd"/test1 | grep -v -f - "$pwd"/test1
我想获取只有失败值的列,或者它们在任何行中都没有完成。
【问题讨论】:
-
StackOverflow 不是一个“我们会为你做功课”的网站。展示你的努力,而不是要求一个现成的解决方案。显示您需要帮助的具体错误
-
sed -n '/Completed/s,(.) 。已完成$,\1,a' "$pwd"/test1 | grep -v -f - "$pwd"/test1 这是我已经完成的,它适用于早期的其他文件,但不适用于这个..
-
编辑您的问题。不要在 cmets 中添加额外的说明......
-
寻求代码帮助的问题必须包括在问题本身中重现它所需的最短代码,最好在Stack Snippet 中。请参阅如何创建 Minimal, Reproducible Example。在您的问题中显示预期结果并引用您遇到的任何(确切)错误也非常有帮助。您应该展示自己为解决这个问题所做的任何研究。
标签: bash shell multiple-columns