How to reverse column order of a file in Linux from the command line

后端 未结 4 494
长发绾君心
长发绾君心 2021-01-04 03:59

I have a file named ip-list with two columns:

IP1    Server1
IP2    Server2

And I want to produce:

4条回答
  •  -上瘾入骨i
    2021-01-04 05:01

    perl -pi -e 's/^([^\t]+)\t([^\t]+)$/\2\t\1/' yourfile.csv

    perl -pi -e 'split("\t"); print "$_[1]\t$_[0]"'

    The first one probably works on sed, too.

提交回复
热议问题