![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sort ascending and descending | don_0110 | UNIX for Dummies Questions & Answers | 1 | 11-27-2008 03:59 PM |
| Sort Descending | saint2006 | Shell Programming and Scripting | 1 | 05-19-2008 02:20 PM |
| Sort Numbers in ascending orders | Raynon | Shell Programming and Scripting | 7 | 01-19-2007 02:03 AM |
| how to see disk usage in descending order | asutoshch | UNIX for Dummies Questions & Answers | 8 | 09-18-2001 08:58 PM |
| Sort / ascending order | gyik | UNIX for Dummies Questions & Answers | 1 | 03-05-2001 10:08 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Ascending & Descending order numbers
Dear All,
I have below attached file in which i have many nos, i want the last ascending order nos. The brief description is given below. File 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 433 315 381 432 315 381 432 315 381 432 315 381 432 315 381 382 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 The required out put must be as given below. (Only last ascending nos) 315 381 432 |
|
||||
|
Actually the cat is useless, and you can use sort -u to avoid the uniq. You probably want numeric sort anyway.
Code:
sort -nu file | tail -n 3 |
|
||||
|
Hi Pravani,
try this val=`tail -1 filename` \rm temp val=`tail -1 filename` echo $val >> temp j=2; for i in `cat filename` do val=`tail -$j filename | head -1 ` if [ $val -ge $val2 ] then break else echo $val >> temp val2=$val j=`expr $j + 1` fi done sort -n temp Thanks Penchal |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|