Visit Our UNIX and Linux User Community

Top Forums Shell Programming and Scripting Sort alpha on 1st field, numerical on 2nd field (sci notation) Post 302324978 by radoulov on Friday 12th of June 2009 10:45:19 AM
Old 06-12-2009
perl -e'
    print sort {
             ( split /\|\|\|/, $a )[0] cmp( split /\|\|\|/, $b )[0]
          || ( split /\|\|\|/, $b )[1] <=> ( split /\|\|\|/, $a )[1]
    } <>;
    ' infile

Last edited by radoulov; 06-12-2009 at 03:03 PM..
Test Your Knowledge in Computers #150
Difficulty: Easy
Oracle discontinued OpenSolaris after their acquisition of Sun Microsystems.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort columns by field

hello, i have a table contain many columns delimited by blank. i want to sort this table by the 2 columns and 3 one and i want to keep the first line inchanged? how can i do using the sort command? thanks table like : field1 field2 field3 field4 x y z b t h r n .. (4 Replies)
Discussion started by: kamel.seg
4 Replies

2. Shell Programming and Scripting

get a name according to the 2nd field

Hi, I have a file with this format: name number -------------- ----------- AAA 11700 BBB 6000 CCC 6000 I want to catch any of these names if number > 200 How to do that? at a... (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

3. UNIX for Advanced & Expert Users

Sort on basis of particular field

05.50.25:AIRE.S:RESTRICTED:S2: 05.50.25:ANDR.VI:RESTRICTED:S2: 05.50.25:BASF.MI:RESTRICTED:N: 05.50.25:BMWG.DE:RESTRICTED:N: 05.50.25:BORE.ST:RESTRICTED:N: I can sort of the basis of second field using " sort -t: -k2,2 " but what i want to sort the data is on the basis its extension e.g.:... (9 Replies)
Discussion started by: manishma71
9 Replies

4. Shell Programming and Scripting

Appending 1st field in a file into 2nd field in another file

Hi, I've internally searched through forums for about 2+ hours. Unfortunately, with no luck. Although I've found some cases close to mine below, but didn't help so much. Actually, I'm in short with time. So I had to post my case. Hoping that you can help. I have 2 files, FILE1 ... (0 Replies)
Discussion started by: amurib
0 Replies

5. Shell Programming and Scripting

Append 1st field from a file into 2nd field of another file

Hi, I've internally searched through forums for about 2+ hours. Unfortunately, with no luck. Although I've found some cases close to mine below, but didn't help so much. Actually, I'm in short with time. So I had to post my case. Hoping that you can help. I have 2 files, FILE1 ... (1 Reply)
Discussion started by: amurib
1 Replies

6. Shell Programming and Scripting

Sort help on non numeric field

Hi, I am unable to sort data on the first field $cat t Jim,212121,Seattle Bill,404404,Seattle Steve,246810,Nevada Scott,212277,LosAngeles Jim,212121,Ohio sort -t"," -k1,2 t Bill,404404,Seattle Jim,212121,Ohio Jim,212121,Seattle Scott,212277,LosAngeles Steve,246810,Nevada (7 Replies)
Discussion started by: Shivdatta
7 Replies

7. Shell Programming and Scripting

how to find the 2nd field

java....4059... compsite 62u IPv4 170747 TCP *:9400 (LISTEN) java...... 05... compsite 109u IPv4 171216 TCP *:9401 (LISTEN) This is Joust formated like this Please Repace "." with space" " All are Right Justfied Output :- 4058 and 05 so that i can kill this (1 Reply)
Discussion started by: pareshpatra
1 Replies

8. Shell Programming and Scripting

Sort field and uniq

I have a flatfile A.txt 2012/12/04 14:06:07 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:07:22 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:13:27 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 14:07:39 |rain|Boards 1|tampa|merced|merced11 How do i sort and get... (3 Replies)
Discussion started by: sabercats
3 Replies

9. UNIX for Dummies Questions & Answers

Combine Similar Output from the 2nd field w.r.t 1st Field

Hi, For example: I have: HostA,XYZ HostB,XYZ HostC,ABC I would like the output to be: HostA,HostB: XYZ HostC:ABC How can I achieve this? So far what I though of is: (1 Reply)
Discussion started by: alvinoo
1 Replies
textutil::split(n)				    Text and string utilities, macro processing 				textutil::split(n)


textutil::split - Procedures to split texts SYNOPSIS
package require Tcl 8.2 package require textutil::split ?0.7? ::textutil::split::splitn string ?len? ::textutil::split::splitx string ?regexp? _________________________________________________________________ DESCRIPTION
The package textutil::split provides commands that split strings by size and arbitrary regular expressions. The complete set of procedures is described below. ::textutil::split::splitn string ?len? This command splits the given string into chunks of len characters and returns a list containing these chunks. The argument len defaults to 1 if none is specified. A negative length is not allowed and will cause the command to throw an error. Providing an empty string as input is allowed, the command will then return an empty list. If the length of the string is not an entire multiple of the chunk length, then the last chunk in the generated list will be shorter than len. ::textutil::split::splitx string ?regexp? This command splits the string and return a list. The string is split according to the regular expression regexp instead of a simple list of chars. Note that if you parentheses are added into the regexp, the parentheses part of separator will be added into the result list as additional element. If the string is empty the result is the empty list, like for split. If regexp is empty the string is split at every character, like split does. The regular expression regexp defaults to "[\t \r\n]+". BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category textutil of the Tcllib SF Trackers []. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
regexp(n), split(n), string(n) KEYWORDS
regular expression, split, string CATEGORY
Text processing textutil 0.7 textutil::split(n)

Featured Tech Videos

All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy