[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

sort not working as expected

Posted on 2011-05-08
3
Medium Priority
?
282 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:andieje
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 35717042
sort -nk1.4 << END
xxx1
xxx23
xxx15
xxx10
END
xxx1
xxx10
xxx15
xxx23
0
 

Author Comment

by:andieje
ID: 35717060
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
0
 

Author Comment

by:andieje
ID: 35717091
i guess the easiest thing would be to separate the data into 2 files, sort them and then merge again
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question