|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help to sort out... Possible use of sort command
I have an input like
4.3.6.66 4.3.6.67 4.3.6.70 4.3.6.25 4.3.6.15 4.3.6.54 4.3.6.44 4.3.6.34 4.3.6.24 4.3.6.14 4.3.6.53 4.3.6.43 4.3.6.49 4.3.6.33 4.3.6.52 4.3.6.19 4.3.6.58 4.3.6.42 4.3.6.48 4.3.6.32 4.3.6.38 4.3.6.22 4.3.6.12 4.3.6.51 4.3.6.18 4.3.6.47 4.3.6.31 4.3.6.37 4.3.6.21 4.3.6.27 4.3.6.50 4.3.6.17 4.3.6.46 4.3.6.30 4.3.6.36 4.3.6.20 4.3.6.26 4.3.6.65 4.3.6.16 4.3.6.45 4.3.6.35 4.3.6.82 4.3.6.88 4.3.6.87 4.3.6.86 4.3.6.84 4.3.6.83 4.3.6.89 4.3.6.91 4.3.6.92 4.3.6.93 4.3.6.94 4.3.6.96 4.3.6.100 4.3.6.99 4.3.6.102 4.3.6.103 someone please help me in sorting the above I/P. I used sort -n, but it doesn't work properly. Please also explain how the command or option works there. |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
Code:
sed 's/\./ /g' input.txt | sort -n -k 4 | sed 's/ /./g' |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
Code:
sort -t'.' -nk4 infile --ahamed |
|
#4
|
|||
|
|||
|
Thanks Ahamed. It helped...
![]() |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
GNU sort has -V option for sorting versions.
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Code:
sort -nt. -k1.1 -k2.2 -k3.3 -k4.4 infile |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sort command help | Olivia | UNIX for Dummies Questions & Answers | 6 | 11-10-2011 04:47 PM |
| Is it Possible to sort a list of hexadecimal numbers using "sort" command? | Kesavan | Shell Programming and Scripting | 9 | 08-21-2011 08:33 AM |
| Script to sort the files and append the extension .sort to the sorted version of the file | pankaj80 | UNIX for Advanced & Expert Users | 3 | 06-07-2011 09:28 AM |
| How to Sort Floating Numbers Using the Sort Command? | daniel.gbaena | Shell Programming and Scripting | 7 | 05-16-2010 11:20 AM |
| using cut command with sort | hankooknara | Shell Programming and Scripting | 5 | 01-03-2007 02:06 AM |
|
|