Sponsored Content
Full Discussion: Numeric sort error
Top Forums Shell Programming and Scripting Numeric sort error Post 302323604 by Panos1962 on Monday 8th of June 2009 12:39:44 PM
Old 06-08-2009
Not so clear

Dera friend, I've also encountered the same problems in the past. I'm using the "n" qualifier for numeric fields to avoid such problems. Your example, though, has a dark point: you want numerical sort (-n) but there are non-numeric fields in the sort. Look the -k option too. Not helped a lot but it's nice to find someone to hear.
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

help newb at linux and bash need numeric script sort

I am trying to setup to automatically import a series of mysql database files. I am doing manually now and its a royal pain. All the sql files are sequentially numbered in a format of 4 numbers underscore text with spaces replaced by underscores. example: There are 3 databases each setup... (1 Reply)
Discussion started by: dlm1065
1 Replies

3. Linux

Using sort command to get numeric ascending order

HI everyone, I am trying to use the unix sort command to get a list of numbers sorted in ascending order but having trouble in getting it to work. An example of this issue would be when i am trying to sort the following three number each on a different line "1" , "2" and "116" the sort command... (3 Replies)
Discussion started by: wali4813
3 Replies

4. Shell Programming and Scripting

Perl script to sort data on second numeric field

Hi, I'm a learner of PERL programming. I've a input file with the below data: SWAT_5, 1703, 2010-09-21 SWAT_6, 2345, 2010-09-21 SWAT_7, 1792, 2010-09-21 SWAT_8, 1662, 2010-09-21 SWAT_9, 1888, 2010-09-21 VXHARP_1, 171, 2010-09-21 I need to sort this data based on the second... (6 Replies)
Discussion started by: ganapati
6 Replies

5. 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

6. 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

7. 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

8. Shell Programming and Scripting

[Solved] sort on numeric part of field

I have ran into a heavy case of PEBCAK*) and could need some advice on what i do wrong: OS is Linux (kernel 2.6.35), sort --version reports "8.5" from 2010, shell is ksh. Originally i had a file with with the following structure: hdisk1 yyy hdisk2 yyy hdisk3 yyy hdisk4 yyy hdisk5 yyy... (2 Replies)
Discussion started by: bakunin
2 Replies

9. 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

10. UNIX for Advanced & Expert Users

Sort by second column numeric values

From googling and reading man pages I figured out this sorts the first column by numeric values. sort -g -k 1,1 Why does the -n option not work? The man pages were a bit confusing. And what if I want to sort the second column numerically? I haven't been able to figure that out. The file... (7 Replies)
Discussion started by: cokedude
7 Replies
INTTYPES(3)						   BSD Library Functions Manual 					       INTTYPES(3)

NAME
inttypes -- standard fixed-size integer types SYNOPSIS
#include <inttypes.h> DESCRIPTION
The <inttypes.h> header describes a set of format specifier macros aimed to increase portability both within and across operating systems. It includes the <stdint.h> header and extends it with additional facilities. Each of the following macros expand to a character string literal containing the format specifier suitable for use within the format argument of a formatted I/O function such as printf(3). Each macro contains an identifier (PRI or SCN), a conversion specifier, and a possible length modifier. The length modifier follows the integer types described in stdint(3): int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t int_least8_t uint_least8_t int_least16_t uint_least16_t int_least32_t uint_least32_t int_least64_t uint_least64_t int_fast8_t uint_fast8_t int_fast16_t uint_fast16_t int_fast32_t uint_fast32_t int_fast64_t uint_fast64_t intmax_t uintmax_t intptr_t uintptr_t The following format specifiers are defined for the fprintf(3) and fscanf(3) families, respectively: PRI?8 SCN?8 PRI?16 SCN?16 PRI?32 SCN?32 PRI?64 SCN?64 PRI?LEAST8 SCN?LEAST8 PRI?LEAST16 SCN?LEAST16 PRI?LEAST32 SCN?LEAST32 PRI?LEAST64 SCN?LEAST64 PRI?FAST8 SCN?FAST8 PRI?FAST16 SCN?FAST16 PRI?FAST32 SCN?FAST32 PRI?FAST64 SCN?FAST64 PRI?MAX SCN?MAX PRI?PTR SCN?PTR The available conversion specifiers, ``?'' in above, are d and i for signed integers and o, u, x, and X for unsigned integers. The X is not available for the fscanf(3) family. Without the length modifier these would correspond with %d, %i, %o, %u, %x, and %X, respectively. EXAMPLES
The following example demonstrates typical usage: uint64_t i = 123; ... (void)printf("i = %"PRIu64" ", i); SEE ALSO
printf(3), scanf(3), stdint(3) STANDARDS
The <inttypes.h> header conforms to ISO/IEC 9899:1999 (``ISO C99'') and IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The <inttypes.h> header was first introduced in NetBSD 1.6. BSD
March 21, 2010 BSD
All times are GMT -4. The time now is 02:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy