行の一部を抽出してソートします。

行の一部を抽出してソートします。

私の出力は次のようになります。

[test output] my name is bob this is a random string
[test output] my name is jim this is a randong string2
[test output] my name is bob this is a randong string3
[test output] my name is alice this is a randong string4
[test output] my name is bob this is a randong string5
[test output] my name is dave this is a randong string6
[test output] my name is jim this is a randong string7
[test output] my name is jim this is a randong string8

予想出力:

my name is bob
my name is jim
my name is alice
my name is dave

上記の内容を名前ごとに1行ずつ出力しようとしました。名前の後に任意の文字列を含めることができます。どの順序で表示されるかは問題ではありません。

誰でも助けることができますか?

ベストアンサー1

そしてawk

awk '{ s = $3" "$4" "$5" "$6 };!(s in a){a[s];print s}' <file

おすすめ記事