Link to home
Start Free TrialLog in
Avatar of andieje
andieje

asked on

sort not working as expected

Hi

I have a data file which has data of this form in column1

xxx1
xxx23
xxx15

I want to sort numerically on the numbers after the 3 x's so i tried this command

sort -nk1.3

but xxx10 is coming before xxx1

thanks
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andieje
andieje

ASKER

note typo in question should have been a 4 not 3

thanks - it wasn't working because it turns out there are some characters instead of numbers

when sort encounters a character in a numerical sort it puts the characters first. is there any way to get the characters at the end? e.g. sort numerically if a number and sort alphabetically if a letter and put the numbers before the letters
Avatar of andieje

ASKER

i guess the easiest thing would be to separate the data into 2 files, sort them and then merge again