Re: Cut command behaviour - bug or feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Rajagopal Swaminathan wrote:
> Greetings,
>
> I have a CSV file with three fields.
> eg.
>
> a1,b1,c1
> a2,b2,c2
> ....
>
> I wanted the output to be:
> b1,c1,a1
> b2,c2,a2
> ....
>
> the command
> cut -d, -f2,3,1 <file>
>
> returns
>
> a1,b1,c1
>
> cut -d, -f2,3 <file>
>
> works as advertised.
>
> Is it specific to linux?
>
> In that case how do I go about swapping two columns? I do not think a
> gazzillion byte gui is required.
>
> The file size is about 43Megs.

I've never been that good with cut. I'm going to see the author, Dave
Ihnat this weekend, who sometimes shows up here... but in the meantime,
you might use
awk 'BEGIN {FS=",";}{print $2 "," $3 "," $1;}' infile

       mark

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux