在引号之间说出来

use*_*608 4 unix linux awk grep sed

我有这样的x行:

Unable to find latest released revision of 'CONTRIB_046578'.   
Run Code Online (Sandbox Code Playgroud)

我需要提取的字revision of ''词在这个例子中CONTRIB_046578 ,如果可能计数用这个词的出现次数grep,sed或任何其他命令?

Chr*_*our 8

最干净的解决方案是 grep -Po "(?<=')[^']+(?=')"

$ cat file
Unable to find latest released revision of 'CONTRIB_046578'
Unable to find latest released revision of 'foo'
Unable to find latest released revision of 'bar'
Unable to find latest released revision of 'CONTRIB_046578'

# Print occurences 
$ grep -Po "(?<=')[^']+(?=')" file
CONTRIB_046578
foo
bar
CONTRIB_046578

# Count occurences
$ grep -Pc "(?<=')[^']+(?=')" file
4

# Count unique occurrences 
$ grep -Po "(?<=')[^']+(?=')" file | sort | uniq -c 
2 CONTRIB_046578
1 bar
1 foo
Run Code Online (Sandbox Code Playgroud)