sort columns in text file

need to sort the following txt file on the second column.
sort +1 -2 body.txt did not work, nor did sort -k 35,50 body.txt nor did sort -t\t +1 -2 body.txt

Oracle Programming                 Sunderraman      in                
Unix for Programmers and Users     Glass            in                
Java Programming                   King             out   10/12/99    Smith
C Programming                      King             out   4/1/10      Jackson
Database Systems                   ElMasri          out   12/5/99     Jones
Discrete Math                      Jackson          in                
Extreme Intelligence               Jackson          in  

the first field is 35 chars, second is 15 chars.

thanks
jjackson2004Asked:
Who is Participating?
 
shajithchandranCommented:
Try sort -t: -k1.35b body.txt
0
 
Bryan ButlerCommented:
This worked for me:

> Sort -k 35,50 body.txt
C Programming                      King             out   4/1/10      Jackson
Database Systems                   ElMasri          out   12/5/99     Jones
Discrete Math                      Jackson          in
Extreme Intelligence               Jackson          in
Java Programming                   King             out   10/12/99    Smith
Oracle Programming                 Sunderraman      in
Unix for Programmers and Users     Glass            in

0
 
Bryan ButlerCommented:
What error or output did you get?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
jjackson2004Author Commented:
no error, it just would not sort on anything other than the beginning of the line.
0
 
shajithchandranCommented:
it would be good if while generating the this file, separate field with | rather than space. That way it would be easy to sort it.
0
 
shajithchandranCommented:
i just changed the field separator to : which doesnt exist in the line.. so the whole line becomes the first field. Than i sorted it based on the 35character to get sort based on the field that you were interested in.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.