On Tue, Aug 28, 2012 at 2:59 PM, Rajagopal Swaminathan <raju.rajsand at gmail.com> wrote: > 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? If you are sure that the fields will never contain commas, there are any number of ways to split lines into variables in any number of scripting languages including bash. However, if the input is 'generic csv' that is allowed to have quotes around fields with embedded commas it can be hard to parse. I'd recommend perl with the Text::CSV module so you don't have to deal with parsing yourself. -- Les Mikesell lesmikesell at gmail.com