sed - How to arrange the lines in ascending order -
i have folder contains 200 pdb files.i arrange atom lines of pdb files in ascending order based on 6th column. in-place editing each pdb file in folder. appreciated.
atom 81 n asn 248 38.791 -16.708 12.507 1.00 52.04 n atom 82 ca asn 248 39.443 -17.018 11.206 1.00 54.49 c atom 422 c ser 205 70.124 -29.955 8.226 1.00 55.81 c atom 423 o ser 205 70.901 -29.008 8.438 1.00 46.60 o atom 303 n met 231 61.031 -38.086 -3.054 1.00 52.32 n atom 304 ca met 231 60.580 -39.074 -4.047 1.00 64.11 c atom 392 c glu b 65 23.248 10.071 -7.321 1.00 48.26 c atom 393 o glu b 65 24.465 10.200 -7.158 1.00 46.53 o atom 394 o glu b 65 24.465 10.200 -7.158 1.00 46.53 o
desired output
atom 392 c glu b 65 23.248 10.071 -7.321 1.00 48.26 c atom 393 o glu b 65 24.465 10.200 -7.158 1.00 46.53 o atom 394 o glu b 65 24.465 10.200 -7.158 1.00 46.53 o atom 422 c ser 205 70.124 -29.955 8.226 1.00 55.81 c atom 423 o ser 205 70.901 -29.008 8.438 1.00 46.60 o atom 303 n met 231 61.031 -38.086 -3.054 1.00 52.32 n atom 304 ca met 231 60.580 -39.074 -4.047 1.00 64.11 c atom 81 n asn 248 38.791 -16.708 12.507 1.00 52.04 n atom 82 ca asn 248 39.443 -17.018 11.206 1.00 54.49 c
use sort
.
sort -n -k 6 inputfile
-n
performs numeric sort, , -k
tells sort via key.
edit: in-place sorting, use -o
option:
sort -n -k 6 inputfile -o inputfile
Comments
Post a Comment