bashir
bashir

Reputation: 21

Sort in bash - how to sort by characters lying middle or end of line

I have the following pdf files to be combined.

20121024aC004101
20121024a_002101
20121024a_003101
20121024aN006101
20121024aA001101
20121024a_005101
etc...

But my result should be in the order of 00101, 002101... i.e. sort based on 11th charater; anybody can help me. I am new to bash, recently started to learn.

Upvotes: 2

Views: 518

Answers (1)

choroba
choroba

Reputation: 241998

Use

sort -k1.11

The -k switch tells sort to sort on the first field from the 11th character.

Upvotes: 9

Related Questions