Sponsored Content
Full Discussion: counts based on percentage
Top Forums Shell Programming and Scripting counts based on percentage Post 302544754 by rdcwayx on Friday 5th of August 2011 12:06:43 AM
Old 08-05-2011
Code:
awk '{a[int($2/10)*10]++}END{for (i in a) print i "-" i+10, a[i]|"sort -n"}' infile

Some updates based on Chubler_XL's code below

Code:
awk '{a[int($2/10)*10]++}END{for (i=0;i<100;i+=10) print i+1 "-" i+10, 0+a[i]}' infile


Last edited by rdcwayx; 08-05-2011 at 01:34 AM..
This User Gave Thanks to rdcwayx For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

counts

How can i do a simple record count in my shell script? i just want to count the number of records i receive from a specific file. (11 Replies)
Discussion started by: k@ssidy
11 Replies

2. UNIX for Dummies Questions & Answers

counts

To start I have a table that has ticketholders. Each ticket holder has a unique number and each ticket holder is associated to a so called household number. You can have multiple guests w/i a household. I would like to create 3 flags (form a, for a household that has 1-4 gst) form b 5-8 gsts... (3 Replies)
Discussion started by: sbr262
3 Replies

3. UNIX for Dummies Questions & Answers

wc -c counts 1 char more per line

Hi, this might be a basic question... why is that wc -c counts 1 more per line than what is there. for example, > cat dum1.txt 123 12 > wc -c dum1.txt 7 dum1.txt Thanks, Sameer. (4 Replies)
Discussion started by: ensameer
4 Replies

4. Shell Programming and Scripting

Counts based on occurances

Hi, I have a file with 2500 entries. There are many duplicates,triplicates symbols in my file in the first column and the second column has categories(high/medium/low) . I want to have count for the occurances of each category for each unique symbol ABC high ABC high ABC medium ABC ... (2 Replies)
Discussion started by: Diya123
2 Replies

5. Shell Programming and Scripting

Filtering lines for column elements based on corresponding counts in another column

Hi, I have a file like this ACC 2 2 21 aaa AC 443 3 22 aaa GCT 76 1 33 xxx TCG 34 2 33 aaa ACGT 33 1 22 ggg TTC 99 3 44 wee CCA 33 2 33 ggg AAC 1 3 55 ddd TTG 10 1 22 ddd TTGC 98 3 22 ddd GCT 23 1 21 sds GTC 23 4 32 sds ACGT 32 2 33 vvv CGT 11 2 33 eee CCC 87 2 44... (1 Reply)
Discussion started by: polsum
1 Replies

6. UNIX for Dummies Questions & Answers

Get counts from List

This is very easy , but I`m struggling .. please help modify my script, I want to count the number of h and n , from the second column group by the first. The second column is binary, can only have h and n. a h a h a n a n a h b h b h b h b h b h c n c h c h c h c h (2 Replies)
Discussion started by: jianp83
2 Replies

7. Shell Programming and Scripting

Different counts between programs and commands

In the attached file if I do a count for "aaaaaaaaaaaa" in either notepad++ or excel I get 118,456. However, when I do either grep -o aaaaaaaaaaaa 12A.txt | wc -w or awk '{ for (i=1;i<=NF;i++) if ( $i == "aaaaaaaaaaaa") c++ } END{ print c}' 12A.txt I... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Solaris

Capture PRSTAT based on CPU usage percentage

Hi, Recently i have write a simple script to capture CPU high usage based on prstat but i found out that it did capture correctly. I need to capture the rows that contains CPU usage more than 3%. Below line which i thought will capture CPU usage based CPU column in prstat(9th parameter) which is... (3 Replies)
Discussion started by: tharmendran
3 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 06:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy