Sponsored Content
Top Forums Shell Programming and Scripting FASTEST way to loop a script 10k times Post 302604759 by quincyjones on Tuesday 6th of March 2012 06:37:29 AM
Old 03-06-2012
Yeah sorry for explaining clear. I spend some time explain thing more clearly and also included some coded that i needed to add.

I need to calculate the mean and standard deviation of the 7th column keys by using output1 to output10000.
For ex:

Code:
output1
col1 col2 col3 col4 col5 col6 col7
abc1 10 20 x.a.1 0 + key1
abc1 15 20 x.a.2 0 + key1
abc1 10 20 y.a.1 0 + key2
abc1 10 20 c.a.1 0 + key2
abc1 10 20 r.a.1 0 + key2
abc1 50 80 m.a.1 0 - key_3

output2
col1 col2 col3 col4 col5 col6 col7
abc1    5    20    x.a.1    0    +    key1
abc1    105    200    x.a.2    0    +    key1
abc1    150    250 y.a.1    0    +    key2
abc1    130    240    c.a.1    0    +    key3
abc1    130    220    r.a.1    0    +    key3
abc1    500    800    m.a.1    0    -    key_3

output10k
....................................

The count the keys based on output

Code:
output1_key1    2
outut1_key2    3
output1_key_3    1
output1_key1    2
outut1_key2    3
output1_key_3    1
output10k_key..........

Then calculate mean using
Code:
awk ‘{s+=$2} END{print “Sum: “s, “\nNumber of lines: “NR, “\nAverage: “s/(NR)}’

Then calculate standard deviation using
Code:
awk ‘{sum+=$2;sumsq+=$2*$2} END {print sqrt(sumsq/NR – (sum/NR)^2)}’

final output
Code:
key    mean    s.d
key1
key2
key_3
......
key_16

---------- Post updated at 06:37 AM ---------- Previous update was at 12:44 AM ----------

I wrote more clear explanation. Please let me know it is clear enough. Thanx

Last edited by quincyjones; 03-06-2012 at 07:36 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help script for login times

I am new to shellscript . PLease help me how can I write the following script. $ who ray pts/0 aug 31 01:18 ( 65.169.28.200 ) ray pts/1 sep 2 02:28 ( 65.169.28.200 ) bob pts/3 sep 2 02:31 ( 65.169.28.201 ) when run the command who |./ script , the script should... (3 Replies)
Discussion started by: LAY
3 Replies

2. Shell Programming and Scripting

Loop to check for file up to 3 times

Please forgive this I think rather basic question. I have been away from UNIX for a very long time and am in need of some help. I need to be able to check for the existance of a specific file name say 'file.dat' in a particular location If the file exists then run a second process (at... (2 Replies)
Discussion started by: JohnCrump
2 Replies

3. UNIX for Dummies Questions & Answers

how to cut selected 10k lines continuosly

I have a source file having 20lacs lines i want to cut first 1 lac lines from source file and redirect to other file (i.e after redirecting the output to other file the source file should have only 19 lacs count ). Pls help me in getting solution. Thanks in advance. (9 Replies)
Discussion started by: vamshi
9 Replies

4. Shell Programming and Scripting

script for comparing the times.

Hi, My below output file looks like this. Backup status at Tue Jul 7 03:30:07 EDT 2009 CMLP Job Name Last Start Last End ST Run Pri/Xit ____________________________ ____________________ ____________________ __ _______ ___ tnx415uu 07/06/2009 22:01:41 ----- RU 5547800/1 tnp415uu 07/06/2009... (2 Replies)
Discussion started by: intiraju
2 Replies

5. Shell Programming and Scripting

Breaking the files as 10k recs. per file

Hi, I have a code as given below Set -A _Category="A\ B\ C" for _cat in ${_Category} do sed -e "s:<TABLE_NAME>:${_cat}:g" \ -e "s:<date>:${_dt}:g" \ ${_home}/skl/sq1.sql >> ${_dest}/del_${_dt}.sql fi ... (4 Replies)
Discussion started by: mr_manii
4 Replies

6. Shell Programming and Scripting

The loop was executed $count times

#!/bin/sh count=0 for i in 2 4 6 do echo "i is $i" count='expr $count + 1' done echo "The loop was executed $count times" with these scripts my output is : i is 2 i is 4 i is 6 The loop was executed expr $count + 1 times What should I do to get the value instead of 'expr... (17 Replies)
Discussion started by: ymwong
17 Replies

7. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

8. UNIX for Advanced & Expert Users

System call failed with 127 .. after 500 times when called in loop

Hi Experts, I have a code like this. ===== #include.... int main() { int count = 0; while(1){ printf("\n Interation number is: %d \n ",count); rv = system(" test.sh > log.txt " ); if (-1 == rv) { printf("Could not generate static log: error... (12 Replies)
Discussion started by: binnyjeshan
12 Replies

9. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

10. Shell Programming and Scripting

Loop to execute 2 times and send an email alert

After the successful start of server, it should check the status again, if it is not running ,it should go through the loop for 2 times. Even after two times of execution if still the server is not running it should send an alert email. Please help (1 Reply)
Discussion started by: thomas9192
1 Replies
Locale::Codes::LangFam(3)				User Contributed Perl Documentation				 Locale::Codes::LangFam(3)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. 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 = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_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.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 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.3 2013-02-27 Locale::Codes::LangFam(3)
All times are GMT -4. The time now is 06:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy