libertyforall2
asked on
reverse last two columns using perl or shell
I have the attached file. I want to do 2 things. 1. reverse the last two columns & 3 round all values in the last two columns to the nearest hundredth. A sample file is attached.
so4pap.txt
so4pap.txt
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi lfa2,
To put output in a 2nd file:
perl -lane 'print "$F[0] $F[1] $F[3] $F[2]"' infile.txt >outfile.txt
To modify the input file:
perl -i -lane 'print "$F[0] $F[1] $F[3] $F[2]"' infile.txt
To put output in a 2nd file:
perl -lane 'print "$F[0] $F[1] $F[3] $F[2]"' infile.txt >outfile.txt
To modify the input file:
perl -i -lane 'print "$F[0] $F[1] $F[3] $F[2]"' infile.txt
Or more concisely:
perl -lane 'print "@F[0,1,3,2]"' infile.txt >outfile.txt
or:
perl -i -lane 'print "@F[0,1,3,2]"' infile.txt
perl -lane 'print "@F[0,1,3,2]"' infile.txt >outfile.txt
or:
perl -i -lane 'print "@F[0,1,3,2]"' infile.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I used the last one. It works great!
ASKER