Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to sort the following file by full name
i.e., position 15-52, using sort command. Any help will be appreciated.
E77377370007673777373Bobbinn-Bashy, Handa J +0073300706077
E77377370006673777373Bobbinn-Bashy, Handa J +0079000706070
E77377770006793660076Cirillo, Beth M -0065670706070
E77377370007637333676Williams, Winters T -0037730706077
E77377370006637333676Williams, Winters T -0037300706070
E77377370006637333676Williams, Winters T -0075300706070
E77377770006637566676Williams, Algie J -0076000706070
E77377770007665353675Wilson, Selman H +0076000706077
E77377770007635633563Glenn, Latricia J +0076330706077
E77377370007637336377Horn, Rebecca C +0035050706077
E77377370007700366507Oliver, Melvin B +0036600706077
E77377370006700366507Oliver, Melvin B +0063000706070
E77377770007635390373Bells, Lucia +0077670706077
E77377770006635390373Bells, Lucia +0030000706070
E77377370006673965077Walters, Monk L +0077000706070
E77377770006635739909Bunter, Brenda A +0075730706070
E77377770007635766977Airington, Lucia +0076000706077
E77377770007357305767Miller-Marozi, Fancy C +0076000706077
E77377770006637637093Harris, Lora A +0063330706070
E77377770007639770073Wilamsons, Yvonne +0076330706077
E77377770006639770073Wilamsons, Yvonne +0037670706070
E77377370006367953636Ball, Gita S +0067300706070TIA

First, the positions you want to sort by do not agree with your data file. Therefore, I choose to sort by characters 22 to 30
sort -t \& -k 1.22,1.30 myfile
Since sort by default uses white space for a field delimiter, I choose & because it isn't used ensuring that each record is treated as 1 field. Change the positions to what fits your purpose.
I then use the -k option that allows be to sort field 1 from character position 22 to 30.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |