Command to transpose (swap rows and columns of) a text file

63,473

I'm not sure there's something in coreutils that can do this, but it seems your question has been asked before by people not necessarily interested in an existing tool like you seem to be. The following links may be interesting to you as a last resort in case you can't find a tool that already does this.

For what it's worth, you may want to take a look at the GNU coreutils manual, especially the 4th section

Share:
63,473

Related videos on Youtube

frogstarr78
Author by

frogstarr78

Updated on September 18, 2022

Comments

  • frogstarr78
    frogstarr78 over 1 year

    Is there currently a generic command that will "pivot" input.

    e.g.

    #labeled.file
    name: bob
    title: code monkey
    
    name: joe
    title: pointy haired
    

    is converted to:

    name title
    bob  code monkey
    joe  pointy haired
    

    and vice-versa

  • frogstarr78
    frogstarr78 over 10 years
    Yeah, it doesn't HAVE to be in coreutils. But I figured there was something already out there and know coreutils has similar type commands.
  • Jeff Hewitt
    Jeff Hewitt over 10 years
    @frogstarr78 I understand and for all I know there might be such a command out there. I included the coreutils manual so you can at least rule out the existence of such a command in that bundle. Feel free to unaccept the answer and wait for a more enlightened one.
  • frogstarr78
    frogstarr78 over 10 years
    No worries. I frequent the coreutils docs. Never quite found anything useful. Suspect pr could work. But it's crazy complicated. Per your suggestions this is prob a dup post anyway and likely will be rm'd. Thanks though.