jjackson2004
asked on
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
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
What error or output did you get?
ASKER
no error, it just would not sort on anything other than the beginning of the line.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
> 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