Skip to content

Instantly share code, notes, and snippets.

@koki-h
Last active December 4, 2016 05:54
Show Gist options
  • Select an option

  • Save koki-h/2e65255f0d9b9c750edb02de18951dd9 to your computer and use it in GitHub Desktop.

Select an option

Save koki-h/2e65255f0d9b9c750edb02de18951dd9 to your computer and use it in GitHub Desktop.
ファイルaaaから1,8カラム目を取り出し、1カラム目をキーとして同じキーを持つデータを横で持つようにするワンライナー
cut -f1,8 aaa | ruby -na -e 'require "pp";BEGIN{h={}}; h[$F[0]] ||= [];h[$F[0]] << $F[1]; END{pp h}'
@koki-h
Copy link
Copy Markdown
Author

koki-h commented Dec 4, 2016

-e オプションに渡すrubyスクリプトはシングルクォーテーションで囲むのが無難。ダブルクォーテーションでも実行できるが$をエスケープする必要がある。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment