Sponsored Content
Full Discussion: sort and summarize
Top Forums Shell Programming and Scripting sort and summarize Post 302149699 by ranjithpr on Friday 7th of December 2007 02:04:43 AM
Old 12-07-2007
Try this one

filename=$1
sort $filename|
awk ' BEGIN {FS="+"; prev_key1=""; prev_key2=0; prev_key2=0; first=1; }
{
# print "asdfdafsdfsdfasf|"prev_key1 "|"$1
if($1==prev_key1)
{
prev_key2 += $2;
prev_key3 += $3;
}
else
{
if(!first)
printf("%20.20s+%08.3f+%08.3f\n",prev_key1,prev_key2,prev_key3);
else first=0;
prev_key1 = $1;
prev_key2 = $2;
prev_key3 = $3;
}
}
END {printf("%20.20s+%08.3f+%08.3f\n",prev_key1,prev_key2,prev_key3);}'
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Summarize the sed script

Hi folks, I have a situation where i have a raw file like cat file_raw 776 713 111 0776713113 317-713-114 235776713115 776713116 336713117 77 6 713 118 0776713119 235776713120 and would like to replace all leading zeros with 235, remove all spaces and dashes, and make all... (3 Replies)
Discussion started by: jerkesler
3 Replies

2. Shell Programming and Scripting

1. search 2nd pattern after a pattern and summarize stats

I have two questions. I am sure one of the Guru will be able to help either one or both. 1. Find 2nd occurance of pattern= "Bind variable after pattern="ABN USER Admin" ...... ABN USER Admin <--- I know this string ..... Bind variable ... .. Bind variable <-- Want to print this... (4 Replies)
Discussion started by: ran123
4 Replies

3. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

4. Shell Programming and Scripting

Using SED/AWK to Summarize Log File in 10min Intervals

I have this huge log file on my linux box that gets generated every day. I'm able to extract the information I need; however I really would like it to be broken down every 10mins. Log File Snippet 01:23:45 MARYHADA Maryhadalittle.lamb(): fleece as white as snow 1394 for and everywhere that... (8 Replies)
Discussion started by: ravzter
8 Replies

5. Shell Programming and Scripting

Summarize file with column matching

Guys, Please help me with this code. I have 2GB file to process and shell seems to be the best option. I am a biologist and though I can think of the logic, the commands are beyond me. Any help is greatly appreciated. Please look at the attched file and the requirement will be very clear. I... (6 Replies)
Discussion started by: newbie83
6 Replies

6. Shell Programming and Scripting

Summarize the values from files

One of my process will create a file Market.txt with data like below. Count Markt file 334936 /pdm/data001/P3_Quest_5HT_AMERGE.csv 2770787 /pdm/data001/P3_Quest_ARB_ATACAND.csv 1198143 /pdm/data001/P3_Quest_Bisp_ACTONEL.csv 3821864 /pdm/data001/P3_Quest_CONTRA_ALL_OTHER_CONTRA.csv... (7 Replies)
Discussion started by: katakamvivek
7 Replies

7. Programming

Can someone summarize what exactly this perticular code is doing

#include<stdio.h> #include<string.h> int main() { char a={0,1,2,3,4,5,6,7,8,9}; printf("\n--%s-- unable to access values",a); printf("\n--%d %d-- able to access through direct acess",a,a); printf("\n--%d-- but the failing to read the size\n",strlen(a)); return 0; } (2 Replies)
Discussion started by: hk108
2 Replies

8. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

Bash cript to calculate summarize address

Hi, I need to write a bash script that when i enter two ip address, it will calculate summerize address for them. Examlpe: 192.168.1.27/25 192.168.1.129/25 Result will be: 192.168.1.0/24 can you help me with this script? I even dont know how to start with it (3 Replies)
Discussion started by: Miron
3 Replies

10. Shell Programming and Scripting

Using awk to Summarize Log File in 5min Intervals

I have huge log file that taken every minute and I need the total at 5min intervals. Sample log: #timestamp(yyyymmddhhmm);result;transaction 201703280000;120;6 201703280001;120;3 201703280002;105;3 201703280003;105;5 201703280004;105;5 201703280005;105;4 201703280006;120;2... (2 Replies)
Discussion started by: wwolfking
2 Replies
OCF_HEARTBEAT_PROFTP(7) 					OCF resource agents					   OCF_HEARTBEAT_PROFTP(7)

NAME
ocf_heartbeat_proftpd - OCF Resource Agent compliant FTP script. SYNOPSIS
proftpd [start | stop | monitor | meta-data | validate-all] DESCRIPTION
This script manages Proftpd in an Active-Passive setup SUPPORTED PARAMETERS
binary The Proftpd binary (optional, string, default /usr/sbin/proftpd) conffile The Proftpd configuration file name with full path. For example, "/etc/proftpd.conf" (optional, string, default /etc/proftpd.conf) pidfile The Proftpd PID file. The location of the PID file is configured in the Proftpd configuration file. (optional, string, default /var/run/proftpd.pid) curl_binary The absolute path to the curl binary for monitoring with OCF_CHECK_LEVEL greater zero. (optional, string, default /usr/bin/curl) curl_url The URL which is checked by curl with OCF_CHECK_LEVEL greater zero. (optional, string, default ftp://localhost/) test_user The name of the ftp user for monitoring with OCF_CHECK_LEVEL greater zero. (optional, string, default test) test_pass The password of the ftp user for monitoring with OCF_CHECK_LEVEL greater zero. (optional, string, no default) SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 20s. stop Stops the resource. Suggested minimum timeout: 20s. monitor Performs a detailed status check. Suggested minimum timeout: 20s. Suggested interval: 60s. monitor Performs a detailed status check. Suggested minimum timeout: 20s. Suggested interval: 120s. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 20s. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5s. EXAMPLE
The following is an example configuration for a proftpd resource using the crm(8) shell: primitive p_proftpd ocf:heartbeat:proftpd op monitor depth="0" timeout="20s" interval="60s" op monitor depth="10" timeout="20s" interval="120s" SEE ALSO
http://www.linux-ha.org/wiki/proftpd_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents UNKNOWN 03/09/2014 OCF_HEARTBEAT_PROFTP(7)
All times are GMT -4. The time now is 11:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy