Sponsored Content
Full Discussion: frequency count using shell
Top Forums Shell Programming and Scripting frequency count using shell Post 302712789 by rdrtx1 on Tuesday 9th of October 2012 05:44:28 PM
Old 10-09-2012
Code:
awk '{ A[$2]++ } END { for(X in A) printf("%d\t%.2f%%\n", X, (A[X]*100)/NR) }' inputfile

This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count field frequency in a '|' delimited file

I have a large file with fields delimited by '|', and I want to run some analysis on it. What I want to do is count how many times each field is populated, or list the frequency of population for each field. I am in a Sun OS environment. Thanks, - CB (3 Replies)
Discussion started by: ChicagoBlues
3 Replies

2. Shell Programming and Scripting

Hit count on a shell script

I have a unix shell script (ex.sh) written. How to find out how many users (incl. myself) have run this .sh ? I can insert code snipet at top of script if need be. - Ravi (2 Replies)
Discussion started by: ravi368
2 Replies

3. Shell Programming and Scripting

Help with checking reference data frequency count

reference data GHTAS QER CC N input data NNWQERPROEGHTASTTTGHTASNCC Desired output GHTAS 2 QER 1 CC 1 N 3 (2 Replies)
Discussion started by: perl_beginner
2 Replies

4. Shell Programming and Scripting

shell to find the count fields of each line

hi, i've many unload files with delimiter '|'. I'm trying to load them to the specific tables from those unl's. The problem here is, some unl's are corrupted. To be exact, some files doesnt seem to have the exact number of fields as in the table. So im trying to identify the corrupted... (6 Replies)
Discussion started by: dvah
6 Replies

5. Shell Programming and Scripting

count frequency of words in a file

I need to write a shell script "cmn" that, given an integer k, print the k most common words in descending order of frequency. Example Usage: user@ubuntu:/$ cmn 4 < example.txt :b: (3 Replies)
Discussion started by: mohit_iitk
3 Replies

6. Shell Programming and Scripting

Code for count the frequency of interacting pairs

Hi all, I am trying to analyze my data, and I will need your experience. I have some files with the below format: res1 = TYR res2 = ASN res1 = ASP res2 = SER res1 = TYR res2 = ASN res1 = THR res2 = LYS res1 = THR res2 = TYR etc (many lines) I am... (3 Replies)
Discussion started by: Tzole
3 Replies

7. Shell Programming and Scripting

Shell scripting: frequency of specific word in a string and statistics

Hello friends, I need a BIG help from UNIX collective intelligence: I have a CSV file like this: VALUE,TIMESTAMP,TEXT 1,Sun May 05 16:13:05 +0000 2013,"RT @gracecheree: Praying God sends me a really great man one day. Gotta trust in his timing. 0,Sun May 05 16:13:05 +0000 2013,@sendi__... (19 Replies)
Discussion started by: kraterions
19 Replies

8. Shell Programming and Scripting

Count frequency of unique values in specific column

Hi, I have tab-deliminated data similar to the following: dot is-big 2 dot is-round 3 dot is-gray 4 cat is-big 3 hot in-summer 5 I want to count the frequency of each individual "unique" value in the 1st column. Thus, the desired output would be as follows: dot 3 cat 1 hot 1 is... (5 Replies)
Discussion started by: owwow14
5 Replies

9. Shell Programming and Scripting

Frequency Count of chunked data

Dear all, I have an AWK script which provides frequency of words. However I am interested in getting the frequency of chunked data. This means that I have already produced valid chunks of running text, with each chunk on a line. What I need is a script to count the frequencies of each string. A... (4 Replies)
Discussion started by: gimley
4 Replies

10. Shell Programming and Scripting

Need help for count using shell

Input: person1=1234 website=google.com website=yahoo.com person2=3453 website=google.com website=mail.com person3=4590 website=facebook.com person4=4591 website=facebook.com website=yahoo.com website=google.com website=twitter.com website=example.com (8 Replies)
Discussion started by: buzzme
8 Replies
funcolumnactivate(3)						SAORD Documentation					      funcolumnactivate(3)

NAME
FunColumnActivate - activate Funtools columns SYNOPSIS
#include <funtools.h> void FunColumnActivate(Fun fun, char *s, char *plist) DESCRIPTION
The FunColumnActivate() routine determines which columns (set up by FunColumnSelect()) ultimately will be read and/or written. By default, all columns that are selected using FunColumnSelect() are activated. The FunColumnActivate() routine can be used to turn off/off activa- tion of specific columns. The first argument is the Fun handle associated with this set of columns. The second argument is a space-delimited list of columns to activate or de-activate. Columns preceded by "+" are activated and columns preceded by a "-" are de-activated. If a column is named with- out "+" or "-", it is activated. The reserved strings "$region" and '$n' are used to activate a special columns containing the filter region value and row value, respectively, associated with this row. For example, if a filter containing two circular regions is specified as part of the Funtools file name, this column will contain a value of 1 or 2, depending on which region that row was in. The reserved strings "$x" and "$y" are used to activate the current binning columns. Thus, if the columns DX and DY are specified as binning columns: [sh $] fundisp foo.fits[bincols=(DX,DY)] then "$x" and "$y" will refer to these columns in a call to FunColumnActivate(). In addition, if the activation string contains only columns to be activated, then the routine will de-activate all other columns. Simi- larly, if the activation string contains only columns to de-activate, then the routine will activate all other columns before activating the list. This makes it simple to change the activation state of all columns without having to know all of the column names. For example: o "pi pha time" # only these three columns will be active o "-pi -pha -time" # all but these columns will be active o "pi -pha" # only pi is active, pha is not, others are not o "+pi -pha" # same as above o "pi -pha -time" # only pi is active, all others are not o "pi pha" # pha and pi are active, all others are not o "pi pha -x -y" # pha and pi are active, all others are not You can use the column activation list to reorder columns, since columns are output in the order specified. For example: # default output order fundisp snr.ev'[cir 512 512 .1]' X Y PHA PI TIME DX DY -------- -------- -------- -------- --------------------- -------- -------- 512 512 6 7 79493997.45854475 578 574 512 512 8 9 79494575.58943175 579 573 512 512 5 6 79493631.03866175 578 575 512 512 5 5 79493290.86521725 578 575 512 512 8 9 79493432.00990875 579 573 # re-order the output by specifying explicit order fundisp snr.ev'[cir 512 512 .1]' "time x y dy dx pi pha" TIME X Y DY DX PI PHA --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 512 512 574 578 7 6 79494575.58943175 512 512 573 579 9 8 79493631.03866175 512 512 575 578 6 5 79493290.86521725 512 512 575 578 5 5 79493432.00990875 512 512 573 579 9 8 A "+" sign by itself means to activate all columns, so that you can reorder just a few columns without specifying all of them: # reorder 3 columns and then output the rest fundisp snr.ev'[cir 512 512 .1]' "time pi pha +" TIME PI PHA Y X DX DY --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 7 6 512 512 578 574 79494575.58943175 9 8 512 512 579 573 79493631.03866175 6 5 512 512 578 575 79493290.86521725 5 5 512 512 578 575 79493432.00990875 9 8 512 512 579 573 The column activation/deactivation is performed in the order of the specified column arguments. This means you can mix "+", "-" (which de- activates all columns) and specific column names to reorder and select columns in one command. For example, consider the following: # reorder and de-activate fundisp snr.ev'[cir 512 512 .1]' "time pi pha + -x -y" TIME PI PHA DX DY --------------------- -------- -------- -------- -------- 79493997.45854475 7 6 578 574 79494575.58943175 9 8 579 573 79493631.03866175 6 5 578 575 79493290.86521725 5 5 578 575 79493432.00990875 9 8 579 573 We first activate "time", "pi", and "pha" so that they are output first. We then activate all of the other columns, and then de-activate "x" and "y". Note that this is different from: # probably not what you want ... fundisp snr.ev'[cir 512 512 .1]' "time pi pha -x -y +" TIME PI PHA Y X DX DY --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 7 6 512 512 578 574 79494575.58943175 9 8 512 512 579 573 79493631.03866175 6 5 512 512 578 575 79493290.86521725 5 5 512 512 578 575 79493432.00990875 9 8 512 512 579 573 Here, "x" and "y" are de-activated, but then all columns including "x" and "y" are again re-activated. Typically, FunColumnActivate() uses a list of columns that are passed into the program from the command line. For example, the code for funtable contains the following: char *cols=NULL; /* open the input FITS file */ if( !(fun = FunOpen(argv[1], "rc", NULL)) ) gerror(stderr, "could not FunOpen input file: %s ", argv[1]); /* set active flag for specified columns */ if( argc >= 4 ) cols = argv[3]; FunColumnActivate(fun, cols, NULL); The FunOpen() call sets the default columns to be all columns in the input file. The FunColumnActivate() call then allows the user to con- trol which columns ultimately will be activated (i.e., in this case, written to the new file). For example: funtable test.ev foo.ev "pi pha time" will process only the three columns mentioned, while: funtable test.ev foo.ev "-time" will process all columns except "time". If FunColumnActivate() is called with a null string, then the environment variable FUN_COLUMNS will be used to provide a global value, if present. This is the reason why we call the routine even if no columns are specified on the command line (see example above), instead of calling it this way: /* set active flag for specified columns */ if( argc >= 4 ){ FunColumnActivate(fun, argv[3], NULL); } SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funcolumnactivate(3)
All times are GMT -4. The time now is 08:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy