FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 08-28-2012, 07:59 PM
Rajagopal Swaminathan
 
Default Cut command behaviour - bug or feature

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.

any ideas?

--
Regards,

Rajagopal
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 08-28-2012, 08:06 PM
 
Default Cut command behaviour - bug or feature

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@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 08-28-2012, 08:14 PM
Rajagopal Swaminathan
 
Default Cut command behaviour - bug or feature

Greetings,

On Wed, Aug 29, 2012 at 1:36 AM, <m.roth@5-cent.us> wrote:
>
> 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
>

I tried it on an xp box with GnuWin32 binaries. It barked some error
showing the single quote.

I will try on a centos box later (<grin>which I am silently injecting
[installing] into that env after handwaving the xp</grin>).

--
Regards,

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

Thread Tools




All times are GMT. The time now is 07:13 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org