Created
November 20, 2013 12:38
-
-
Save robmiller/7562495 to your computer and use it in GitHub Desktop.
Ruby one-liner for transposing rows to columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "foo\nbar\nbaz\nfoo\nbar\nbaz" | ruby -pe 'BEGIN{i=0}; $_.chomp! << "\t" unless (i += 1) % 3 == 0' | |
| # Input: | |
| # | |
| # foo | |
| # bar | |
| # baz | |
| # foo | |
| # bar | |
| # baz | |
| # | |
| # Output: | |
| # | |
| # foo bar baz | |
| # foo bar baz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment