[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Switch columns 3 & 4 using perl or shell scripts

Posted on 2011-02-10
3
Medium Priority
?
442 Views
Last Modified: 2012-05-11
If I have a file that looks like this. The date may also be 01/01/11 format and column 3 & 4 may contain whole numbers as well like 2, 3, 4 rounded to the whole number. How would I switch column 3 & 4 while leaving everything else alone?

01-24-2011 14:15:01 0.00 0.00
01-25-2011 02:15:02 0.00 0.00
01-25-2011 14:15:02 0.00 0.00
01-26-2011 02:15:02 0.00 0.00
01-26-2011 14:15:01 0.00 0.00
01-27-2011 02:15:01 0.00 0.00
01-27-2011 14:15:01 0.00 0.00
01-28-2011 02:15:01 0.00 0.00
01-28-2011 14:15:01 0.00 0.00
01-29-2011 02:15:01 0.00 0.00
01-29-2011 14:15:01 0.00 0.00
01-30-2011 02:15:01 0.01 0.00
01-30-2011 14:15:01 0.01 0.01
01-31-2011 02:15:01 0.00 0.00
01-31-2011 14:15:01 0.00 0.00
02-01-2011 02:15:01 0.00 0.00
02-01-2011 14:15:01 0.00 0.00
02-02-2011 02:15:01 0.00 0.00
02-02-2011 14:15:01 0.00 0.00
02-03-2011 02:15:01 0.00 0.00
0
Comment
Question by:libertyforall2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
sshah254 earned 1000 total points
ID: 34867770
In perl, read the line, use the split function (split at spaces) to split the line into array.  Print the line back
with elements 2 & 3 reversed (elements will be 0, 1, 2, and 3 ... 4 elements).

Ss
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 1000 total points
ID: 34867781
perl -lane 'print "@F[0,1,3,2]"'
0
 

Author Closing Comment

by:libertyforall2
ID: 34868346
works great!
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question