Sort by second column numeric values


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Sort by second column numeric values
# 8  
Old 11-16-2015
You're not supplying the comma separator to sort. May I guess your locale allows for the comma being part of a number which would explain the difference between -n and -g options:
Quote:
-g, --general-numeric-sort
compare according to general numerical value
.
.
.
-n, --numeric-sort
compare according to string numerical value
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace a numeric values in a certain column

Hi All, I am trying to replace a certain value from one place in a file . In the below file at position 35 I will have 8 I need to modify all 8 in that position to 7 I tried awk '{gsub("8","7",$35)}1' infile > outfile ----> not working sed -i 's/8/7'g' infile --- it is replacing all... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. Shell Programming and Scripting

Splitting the numeric vs alpha values in a column to distinct columns

How could i take an input file and split the numeric values from the alpha values (123 vs abc) to distinc columns, and if the source is blank to keep it blank (null) in both of the new columns: So if the source file had a column like: Value: |1 | |2.3| | | |No| I would... (7 Replies)
Discussion started by: driftlogic
7 Replies

3. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

4. Shell Programming and Scripting

Sort numeric order

Hi I am using this cat substitutionFeats.txt | gawk '{$0=gensub(/\t/,"blabla",1);print}' | gawk '{print length, $0}' | sort -n | sort -r and the "sort -n" command doesn't work as expected: it leads to a wrong ordering: 64 Adjustable cuffs 64 Abrasion- 64 Abrasion pas 647 Sanitized 647... (4 Replies)
Discussion started by: louisJ
4 Replies

5. UNIX for Dummies Questions & Answers

sort files by numeric filename

dear all, i have .dat files named as: 34.dat 2.dat 16.dat 107.dat i would like to sort them by their filenames as: 2.dat 16.dat 34.dat 107.dat i have tried numerous combinations of sort and ls command (in vain) to obtain : 107.dat 16.dat 2.dat 34.dat (1 Reply)
Discussion started by: chen.xiao.po
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

print unique values of a column and sum up the corresponding values in next column

Hi All, I have a file which is having 3 columns as (string string integer) a b 1 x y 2 p k 5 y y 4 ..... ..... Question: I want get the unique value of column 2 in a sorted way(on column 2) and the sum of the 3rd column of the corresponding rows. e.g the above file should return the... (6 Replies)
Discussion started by: amigarus
6 Replies

8. Shell Programming and Scripting

How to sort values inside one column?

Hi, Could someone please help me with this? I have a text file that has fields seperated by comma. The last column in it has multiple values seperated by "|". I need to sort values in the last column seperated by pipe..is there any way I can do this through script? Sample text file - ... (7 Replies)
Discussion started by: sncoupons
7 Replies

9. Shell Programming and Scripting

Numeric sort error

Hello all I have data like below where the column with values (PRI, SEC ) is the char field and the rest are Numeric Fields. 200707,9580,58,7,2,1,PRI,1,1,137,205594,0,5,10,-45.51,-45.51 200707,9580,58,7,2,1,SEC,1,1,137,205594,0,5,10,-45.51,45.51... (1 Reply)
Discussion started by: vasuarjula
1 Replies

10. Shell Programming and Scripting

how to numeric sort on field time

i want to sort time field given by who command as a whole i have tried like this who|sort -n +4 -5 (1 Reply)
Discussion started by: rahulspatil_111
1 Replies
Login or Register to Ask a Question
CUBRID_FETCH_FIELD(3)							 1						     CUBRID_FETCH_FIELD(3)

cubrid_fetch_field - Get column information from a result and return as an object

SYNOPSIS
object cubrid_fetch_field (resource $result, [int $field_offset]) DESCRIPTION
This function returns an object with certain properties of the specific column. The properties of the object are: o $name -column name o $table -name of the table that the column belongs to o $def -default value of the column o $max_length -maximum length of the column o $not_null -1 if the column cannot be NULL o $primary_key -1 if the column is a primary key o $unique_key -1 if the column is an unique key o $multiple_key -1 if the column is a non-unique key o $numeric -1 if the column is numeric o $blob -1 if the column is a BLOB o $type -the type of the column o $unsigned -1 if the column is unsigned o $zerofill -1 if the column is zero-filled PARAMETERS
o $result -$result comes from a call to cubrid_execute(3) o $field_offset - The numerical field offset. If the field offset is not specified, the next field (that was not yet retrieved by this function) is retrieved. The $field_offset starts at 0. RETURN VALUES
Object with certain properties of the specific column, when process is successful. FALSE on failure. EXAMPLES
Example #1 cubrid_fetch_field(3) example <?php $conn = cubrid_connect("localhost", 33000, "demodb"); $req = cubrid_execute($conn, "SELECT event_code,athlete_code,nation_code,game_date FROM game WHERE host_year=1988 and event_code=20001;"); var_dump(cubrid_fetch_row($req)); cubrid_field_seek($req, 1); $field = cubrid_fetch_field($req); printf(" --- Field Properties --- "); printf("%-30s %s ", "name:", $field->name); printf("%-30s %s ", "table:", $field->table); printf("%-30s "%s" ", "default value:", $field->def); printf("%-30s %d ", "max length:", $field->max_length); printf("%-30s %d ", "not null:", $field->not_null); printf("%-30s %d ", "primary key:", $field->primary_key); printf("%-30s %d ", "unique key:", $field->unique_key); printf("%-30s %d ", "multiple key:", $field->multiple_key); printf("%-30s %d ", "numeric:", $field->numeric); printf("%-30s %d ", "blob:", $field->blob); printf("%-30s %s ", "type:", $field->type); printf("%-30s %d ", "unsigned:", $field->unsigned); printf("%-30s %d ", "zerofill:", $field->zerofill); cubrid_close_request($req); cubrid_disconnect($conn); ?> The above example will output: array(4) { [0]=> string(5) "20001" [1]=> string(5) "16681" [2]=> string(3) "KOR" [3]=> string(9) "1988-9-30" } --- Field Properties --- name: athlete_code table: game default value: "" max length: 0 not null: 1 primary key: 1 unique key: 1 multiple key: 0 numeric: 1 blob: 0 type: integer unsigned: 0 zerofill: 0 PHP Documentation Group CUBRID_FETCH_FIELD(3)