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
Alzabo::Column(3pm)					User Contributed Perl Documentation				       Alzabo::Column(3pm)

NAME
Alzabo::Column - Column objects SYNOPSIS
use Alzabo::Column; foreach my $c ($table->columns) { print $c->name; } DESCRIPTION
This object represents a column. It holds data specific to a column. METHODS
table Returns the table object to which this column belongs. name Returns the column's name as a string. nullable Returns a boolean value indicating whether or not NULLs are allowed in this column. attributes A column's attributes are strings describing the column (for example, valid attributes in MySQL are 'UNSIGNED' or 'ZEROFILL'. This method returns a list of strings of such strings. has_attribute This method can be used to test whether or not a column has a particular attribute. By default, the check is case-insensitive. It takes the following parameters: * attribute => $attribute * case_sensitive => 0 or 1 (defaults to 0) It returns a boolean value indicating whether or not the column has this particular attribute. type Returns the column's type as a string. sequenced The meaning of a sequenced column varies from one RDBMS to another. In those with sequences, it means that a sequence is created and that values for this column will be drawn from it for inserts into this table. In databases without sequences, the nearest analog for a sequence is used (in MySQL the column is given the AUTO_INCREMENT attribute, in Sybase the identity attribute). In general, this only has meaning for the primary key column of a table with a single column primary key. Setting the column as sequenced means its value never has to be provided to when calling "Alzabo::Runtime::Table->insert". Returns a boolean value indicating whether or not this column is sequenced. default Returns the default value of the column as a string, or undef if there is no default. default_is_raw Returns true if the default is intended to be provided to the DBMS as-is, without quoting, fore example "NOW()" or "current_timestamp". length Returns the length attribute of the column, or undef if there is none. precision Returns the precision attribute of the column, or undef if there is none. is_primary_key Returns a boolean value indicating whether or not this column is part of its table's primary key. is_numeric Returns a boolean value indicating whether the column is a numeric type column. is_integer Returns a boolean value indicating whether the column is a numeric type column. is_floating_point Returns a boolean value indicating whether the column is a numeric type column. is_character Returns a boolean value indicating whether the column is a character type column. This is true only for any columns which are defined to hold text data, regardless of size. is_date Returns a boolean value indicating whether the column is a date type column. is_datetime Returns a boolean value indicating whether the column is a datetime type column. is_time Returns a boolean value indicating whether the column is a time type column. is_time_interval Returns a boolean value indicating whether the column is a time interval type column. is_blob Returns a boolean value indicating whether the column is a blob column. This is true for any columns defined to hold binary data, regardless of size. generic_type This methods returns one of the following strings: integer floating_point character date datetime time blob unknown definition The definition object is very rarely of interest. Use the "type()" method if you are only interested in the column's type. This methods returns the "Alzabo::ColumnDefinition" object which holds this column's type information. comment Returns the comment associated with the column object, if any. AUTHOR
Dave Rolsky, <autarch@urth.org> perl v5.8.8 2007-12-23 Alzabo::Column(3pm)