Sponsored Content
Top Forums Shell Programming and Scripting How to calculate what percentage of X value is there in the file? Post 302745573 by Yoda on Monday 17th of December 2012 02:47:32 PM
Old 12-17-2012
Code:
awk ' BEGIN { max=sum=0; th=fv=0; } NR==1 { min=$1; } {
 val=$1;
 sum+=val;
 if(val<min) { min=val; }
 if(val>max) { max=val; }
 if(val>1000) { th++; }
 if(val>5000) { fv++; }
 } END {
 printf "Min: %d Max: %d Avg: %d 1000 per: %d 5000 per: %d\n", min, max, (sum/NR), (th/NR * 100), (fv/NR * 100);
} ' filename

 

10 More Discussions You Might Find Interesting

1. Programming

how do I calculate percentage ?

int percent (int a, int b) { if (b/a*100 > 25) return TRUE; else return FALSE; } I want to calculate what percentage of a is b. say if b = 48, a = 100 so b is 48% of a but wouldnt b/a give me 0 ??? what can be done ?? (6 Replies)
Discussion started by: the_learner
6 Replies

2. Shell Programming and Scripting

How to calculate the percentage for the values in column

Hi, I am having the file which contains the following two columns. 518 _factorial 256 _main 73 _atol 52 ___do_global_ctors 170 ___main 52 ___do_g How can calculate the percentage of each value in the first column ? first need to get the sum of the first column and... (3 Replies)
Discussion started by: saleru_raja
3 Replies

3. Shell Programming and Scripting

How can i calculate percentage ??

i have 3 files like total.dat=18 equal.dat=14 notequal.dat=16 i need find the equal percentange means: equalpercentage = ($equal.dat / $total.dat * 100) How i can do this ? I tried some of the answers to calculate the percentage in this forums.but it couldn't worked.Some one please... (6 Replies)
Discussion started by: bobprabhu
6 Replies

4. Shell Programming and Scripting

Need an AWK script to calculate the percentage

Hi I need a awk script to calculate percentage. I have to pass the pararmeters in to the awk script and calculate the percentage. Sum = 50 passed = 43 failed = 7 I need to pass these value in to the awk script and calculate the percentage. Please advice me. (8 Replies)
Discussion started by: bobprabhu
8 Replies

5. UNIX for Dummies Questions & Answers

Is it possible to extract rows with the same first column and then calculate its percentage?

A short excerpt of my .txt file looks like: CXRA3Z2J9MQKR B CXRA3Z2J9MQKR A CXRA3Z2J9MQKR C CXRA3Z2J9MQKR B A162JX4ML69UIC C A162JX4ML69UIC A FZ9Z19TI2XOA5 A FZ9Z19TI2XOA5 C FZ9Z19TI2XOA5 B FZ9Z19TI2XOA5 B BRNTTJUB8GXE9 A BRNTTJUB8GXE9 A ... (7 Replies)
Discussion started by: pxalpine
7 Replies

6. Shell Programming and Scripting

Script shell, how to calculate percentage?

hello, please can you help me. jj and kk are two numbers which are the result of an sql program. I would like to calculate the ratio jj/kk*100. I have done this: ratio=$((jj/kk * 100)) or ratio=`expr $jj \/ expr $kk) but the result is 0 What can i do? Thanks for help. (3 Replies)
Discussion started by: likeaix
3 Replies

7. Shell Programming and Scripting

Calculate percentage of a value accross m

I have 100 csv files like: file_city_1 file_city_2 file_city_3 file_city_4 City name is variable, there is 25 cities, each city has 4 region. Each of the 4 region contain some statistics like: parameter1 : number1 parameter1 : number2 ..... parameter50 : number50 ... (7 Replies)
Discussion started by: Meacham12
7 Replies

8. Shell Programming and Scripting

Calculate percentage of columns greater than certain value in a matrix using awk

This matrix represents correlation values. Is it possible to calculate the percentage of columns (a1, a2, a3) that have a value >= |0.5| and report the percentage that has positive correlation >0.5 and negative correlation <-0.5 separately. thanx in advance! input name a1 a2 a3... (5 Replies)
Discussion started by: quincyjones
5 Replies

9. Shell Programming and Scripting

Calculate Percentage

Hello, Ive got a bunch of numbers here e.g: 6065 6094 6348 6297 6161 6377 6338 6290 How do I find out if there is a difference between 10% or more between one of these numbers ? I am trying to do this in Bash.. but no luck so far.. Does anyone have an Idea ?? Thanx, - Pascal... (9 Replies)
Discussion started by: denbekker
9 Replies

10. Shell Programming and Scripting

Calculate percentage difference between two columns

I have a input text file in this format: ITEM1 10.9 20.1 ITEM2 11.6 12 ITEM3 14 15.7 ITEM5 20 50.6 ITEM6 25 23.6 I want to print those lines which have more than 5% difference between second and third columns. (8 Replies)
Discussion started by: ctrld
8 Replies
TRAYER(1)						      General Commands Manual							 TRAYER(1)

NAME
trayer - a lightweight GTK2-based systray for UNIX desktop SYNOPSIS
trayer -h trayer -v trayer [--edge left|right|top|bottom|none] [--align left|right|center] [--margin <size>] [--widthtype request|pixel|percent ] [--width <size>] [--heighttype <pixel>] [--height <size>] [--SetDockType true|false] [--SetPartialStrut true|false] [--transparent true|false] [--alpha <value>] [--tint <color>] [--distance <length>] [--distancefrom left|right|top|bottom|none] [--expand true|false] [--padding <size>] DESCRIPTION
trayer is a small program designed to provide system tray similar to these in GNOME / KDE desktop environments for window managers which does not support that function. It is similar to other applications such as peksystray and docker. System tray is a place, where many applications put their icons, so they are always visible. Such icons may present status of an applica- tion and allow user to control the program. trayer's code was extracted from fbpanel application, you can find more about it on its homepage: http://fbpanel.sourceforge.net/. OPTIONS
This programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --help -h Show summary of options and exit. --version -v Show version of program and exit. --edge left|right|top|bottom|none Specifies a screen edge to use. --align left|center|right Specifies an align of the icons. --margin <size> Specifies length of margin (in pixels) --widthtype request|pixel|percent Specifies method of calculating trayer's window width: request Follow application icons' size, so trayer may shrink or expand dynamically. pixel Set a fixed size, given with --width option in pixels. percent Set a fixed size, given with --width option in percentage of a length of screen edge. --width <size> Width of trayer's window. Ignored when --widthtype is set to request. --heighttype request|pixel|percent Specifies method of calculating trayer's window height: request Follow application icons' size, so trayer may shrink or expand dynamically. pixel Set a fixed size, given with --height option in pixels. percent Set a fixed size, given with --height option in percentage of a length of screen edge. --height <size> Height of trayer's window. Ignored when --heighttype is set to request. --SetDockType true|false Identify panel window type as dock. --SetPartialStrut true|false Reserve panel space so that it will not be covered by maximized windows. --transparent true|false Use transparency. --alpha <value> Percentage of transparency (0 - nontransparent, 255 - fully transparent) --tint <color> Color used to tint transparent background. Color is given as a 24-bit C hexadecimal integer, for example: 0xff0000 is red, 0xff8800 is orange and 0x00ff00 is green. --distance <length> Specifies distance between trayer's window and screen edge (in pixels) --distancefrom <edge> Specifies which edge to calculate distance from, see above. --expand true|false Specifies whether trayer may accommodate extra space when there is too much icons. --padding <size> Extra space between icons and trayer window's border. --monitor NUM|STRING Define the monitor on which you like trayer to appear, number of zero to number of monitors minus one, or the string "primary" are valid. The default value is 0. SEE ALSO
fbpanel(1) AUTHORS
Anatoly Asviyan <aanatoly@users.sf.net> - fbpanel Rafal Bisingier <ravbc@man.poznan.pl> Maciej Delmanowski <harnir@users.berlios.de> Grzegorz Nieweglowski <hoppke@dobremiasto.net> Thomas Rydzynski This manual page was written by Tomasz Melcer <liori@interia.pl>. FVWM-Crystal Feb 14, 2005 TRAYER(1)
All times are GMT -4. The time now is 10:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy