次のように情報を出力するログファイルがあります。
2016-01-01: foo bar fnord
2016-01-01: this is static 'this is of interest' some blob bar
2016-01-01: this is static 'this is of interest' some hurz poit
2016-01-01: foo bar fnord
2016-01-01: this is static 'this is of interest as well' some blob bar
一重引用符内の文字列だけを印刷したいと思います。重複したエントリは次のように削除する必要があります。
this is of interest
this is of interest as well
私は引用符の間に何があるかを見つけるために正規表現を試しましたが、うまくいきませんでした。たとえば、次のようになります。
grep -io "static.*" | sed -e '\w+'|'\w+(\s\w+)*'
ベストアンサー1
cut
正規表現を書くよりも使いやすいです。
grep -io "static.*" logfile.txt | cut -d "'" -f2 | sort -u
こうしてみてください。次のように印刷されます。
this is of interest
this is of interest as well