Sponsored Content
Top Forums Shell Programming and Scripting Trouble with alphanumeric Sort Post 302838351 by Don Cragun on Monday 29th of July 2013 11:45:33 AM
Old 07-29-2013
If all of your files are in the same directory (or you want the directory name to be part of the primary sort key, all of your filenames contain 3 underscore characters, and you want the 1st three underscore separated fields sorted alphanumerically and the 4th field to be sorted numerically as the final sort key, the following simple sort command does what you want:
Code:
sort -t_ -k1,3 -k4,4n list

With the sample input you showed, this command produces the output:
Code:
/vol/close_eng_ice_0888
/vol/open_eng_ice_0890
/vol/open_eng_ice_0893
/vol/open_eng_ice_08923
/vol/zebra_eng_ice_022


Last edited by Don Cragun; 07-29-2013 at 12:46 PM.. Reason: Fix typo
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort command - alphanumeric

I have a file I'm trying to sort such as fred1 fred2 fred10 fred11 ... when I sort I get fred1 fred10 fred11 fred2 ... using sort can any give me the syntax to sort this is dict order e.g., (4 Replies)
Discussion started by: gefa
4 Replies

2. UNIX for Dummies Questions & Answers

AlphaNumeric String Operations

Hi :) I am writing a ksh I have a string of general format A12B3456CD78 the string is of variable length the string always ends with numbers (here it is 78.. it can be any number of digits may be 789 or just 7) before these ending numbers are alphabets (here it is CD can even be... (3 Replies)
Discussion started by: lakshmikanth
3 Replies

3. Shell Programming and Scripting

alphanumeric comparision

I have a requirement where I need to check if where r1v07l09ab is a software release. I should always check for this to be true to continue the release deployment because an older release should not be deployed by mistake. I mean only the release greater than the current release should be... (3 Replies)
Discussion started by: rakeshou
3 Replies

4. UNIX for Advanced & Expert Users

alphanumeric Sorting

Hi , I have a requirement where one column have to be sorted (delimiter is pipe) for eg: My input filed is as below 1|FIAT|0010103|23011|01/01/2000|31/12/9999|1.15 2|232|613|1 2|234|743|1 2|234|793|1 2|234|893|1 1|FIAT|0010103|23012|01/01/2000|31/12/9999|1.15 2|230|006|0 2|230|106|0... (9 Replies)
Discussion started by: laxmi131
9 Replies

5. Shell Programming and Scripting

get rid of non-alphanumeric characters

Hi! Could anyone so kindly help me a code to eliminate from a txt file, obtained by collecting and merge several web-page, every word (string) containing non alphabetical, numeric and punctuation character (i.e NON a-zA-Z0-9, underscore and punctuation mark)? Thanks a lot for the help to... (5 Replies)
Discussion started by: mjomba
5 Replies

6. Shell Programming and Scripting

Alphanumeric to integer

Hi folks, I have a value like A12,i could able to change this into integer using typeset as below typeset -i A12 But, I need your advice to change the values like 1A2 or 12A into integer. Thanks in advance. Thanks, Sathish (3 Replies)
Discussion started by: bsathishmca
3 Replies

7. Shell Programming and Scripting

Perl regex and sort trouble

Hi so I have these files where the first thing in them says something along the lines of "This document was accessed 'date' blah blah", I was thinking of a way to extract that date and then sort the files based on that date. My question is how do I get rid of the words in that statement so that... (6 Replies)
Discussion started by: vas28r13
6 Replies

8. UNIX for Dummies Questions & Answers

Parsing alphanumeric variables

Hi All, I have files with a column which has values and ranges, for example colA colB ERD1 3456 ERD2 ERD3 4456 I want to have the following output colA colB colC ERD1 3456 3456 ERD2 526887 526890 ERD3 4456 4456 Being a newbie to... (2 Replies)
Discussion started by: alpesh
2 Replies

9. UNIX for Dummies Questions & Answers

Want to sort a file which contains alphanumeric strings

I want to sort a file which contains alphanumeric string. bash-3.00$ cat abc mtng1so mtng2so mtng11so mtng9so mtng23so mtng7so hstg2so hstg9so hstg1so hstg11so hstg13so bash-3.00$ Want output like this, using one liner. hstg1so (1 Reply)
Discussion started by: Raza Ali
1 Replies

10. Shell Programming and Scripting

Sort two columns with alphanumeric values horizontally

Hi, I have a file like aa bb dmns|860 dmns|756 ee ff aa bb dmns|310 dmns|260 ee ff aa bb dmns|110 dmns|77 ee ff aa bb dmns|756 dmns|860 ee ff aa bb dmns|110 dmns|77 ee ff aa bb dmns|233 dmns|79 ee ff aa bb dmns|79 dmns|233 ee ff I want to sort the values in column3 and column4... (2 Replies)
Discussion started by: sammy777888
2 Replies
RUPTIME(1)						    BSD General Commands Manual 						RUPTIME(1)

NAME
ruptime -- show host status of local machines SYNOPSIS
ruptime [-alrtu] DESCRIPTION
ruptime gives a status line like uptime(1) for each machine on the local network; these are formed from packets broadcast by each host on the network via the rwhod(8) daemon. The default broadcast time by the hosts is every three minutes. Machines for which no status report has been received for 11 minutes are shown as being down. The options are as follows: -a Users idle an hour or more are not counted unless the -a flag is given. -l Sort by load average. -r Reverses the sort order. -t Sort by uptime. -u Sort by number of users. The default listing is sorted by host name. FILES
/var/rwho/whod.* data files SEE ALSO
rup(1), rwho(1), uptime(1), rwhod(8) HISTORY
ruptime appeared in 4.2BSD. BSD
August 9, 2005 BSD
All times are GMT -4. The time now is 08:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy