linux – 在引号之间说出来

linux – 在引号之间说出来,第1张

概述我有这样的x行: Unable to find latest released revision of 'CONTRIB_046578'. 我需要在这个例子中修改’和’之间的单词CONTRIB_046578,如果可能的话,使用grep,sed或任何其他命令计算该单词的出现次数? 您只需要一个非常简单的awk脚本来计算引号之间的内容: awk -F\' '{c[$2]++} END{for (w i 我有这样的x行:

Unable to find latest released revision of 'CONTRIB_046578'.

我需要在这个例子中修改’和’之间的单词CONTRIB_046578,如果可能的话,使用grep,sed或任何其他命令计算该单词的出现次数?

解决方法 您只需要一个非常简单的awk脚本来计算引号之间的内容:

awk -F\' '{c[]++} END{for (w in c) print w,c[w]}' file

使用@ anubhava的测试输入文件:

$cat fileUnable to find latest released revision of 'CONTRIB_046572'Unable to find latest released revision of 'CONTRIB_046578'Unable to find latest released revision of 'CONTRIB_046579'Unable to find latest released revision of 'CONTRIB_046570'Unable to find latest released revision of 'CONTRIB_046579'Unable to find latest released revision of 'CONTRIB_046572'Unable to find latest released revision of 'CONTRIB_046579'$$awk -F\' '{c[]++} END{for (w in c) print w,c[w]}' fileCONTRIB_046578 1CONTRIB_046579 3CONTRIB_046570 1CONTRIB_046572 2
总结

以上是内存溢出为你收集整理的linux – 在引号之间说出来全部内容,希望文章能够帮你解决linux – 在引号之间说出来所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1027879.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存