Sponsored Content
Top Forums Shell Programming and Scripting Grouping and Subgrouping using awk Post 302953799 by RudiC on Tuesday 1st of September 2015 02:49:01 PM
Old 09-01-2015
@Scrutinizer: brilliant and terse; works well if the first epoch time in a group is an integer multiple of 3600 but shifts the entire range output if the time has some additional seconds in it.

@hemanty4u: With the data as given, t is calculated by successive addition of 1, i.e. 400277 loops, while one single division yields the same result. And, in the END section, you print 400283 times your output line. No surprise run time is that long! Try for (a in A) print a, A[a] in the END section.

Last edited by RudiC; 09-02-2015 at 04:26 AM..
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

egrep and grouping

i am using the c shell on solaris. directories i'm working with: ls -1d DIV* DIV_dental/ DIV_ibc/ DIV_ifc/ DIV_index/ DIV_pharm/ DIV_sectionI/ DIV_sectionI-title/ DIV_sectionI-toc/ DIV_sectionII-title/ DIV_sectionII-toc/ DIV_standing/ DIV_standing-toc/ DIV_title/ DIV_vision/ (1 Reply)
Discussion started by: effigy
1 Replies

2. Shell Programming and Scripting

Grouping using sed/awk ?

I run awk cat $1|awk '{print $6}' and get a lot of results and I want results to group them. For example my result is (o/p is unknown to user) xyz xyz abc pqr xyz pqr etc I wanna group them as xyz=total found 7 abc=total .... pqr= Thank (3 Replies)
Discussion started by: pujansrt
3 Replies

3. Shell Programming and Scripting

awk grouping by name script

Hello I am trying to figure out a script which could group a log file by user names. I worked with awk command and I could trim the log file to: <USER: John Frisbie > /* Thu Aug 06 2009 15:11:45.7974 */ FLOAT GRANT WRITE John Frisbie (500 of 3005 write) <USER: Shawn Sanders > /* Thu Aug 06... (2 Replies)
Discussion started by: Avto
2 Replies

4. Shell Programming and Scripting

AWK script to create max value of 3rd column, grouping by first column

Hi, I need an awk script (or whatever shell-construct) that would take data like below and get the max value of 3 column, when grouping by the 1st column. clientname,day-of-month,max-users ----------------------------------- client1,20120610,5 client2,20120610,2 client3,20120610,7... (3 Replies)
Discussion started by: ckmehta
3 Replies

5. Shell Programming and Scripting

awk and perl grouping.

Hello folks. After awk, i have decided to start to learn perl, and i need some help. I have following output : 1 a 1 b 2 k 2 f 3 s 3 p Now with awk i get desired output by issuing : awk ' { a = a FS $2 } END { for ( i in a) print i,a }' input 1 a b 2 k f 3 s p Can... (1 Reply)
Discussion started by: Peasant
1 Replies

6. Shell Programming and Scripting

grouping using sed or awk

I have below inside a file. 11.22.33.44 user1 11.22.33.55 user2 I need this manipulated as alias server1.domain.com='ssh user1@11.22.33.44' alias server2.domain.com='ssh user2@11.22.33.55' (3 Replies)
Discussion started by: anil510
3 Replies

7. Shell Programming and Scripting

Grouping

Hi all, I am using following command: perl program.pl input.txt output.txt CUTOFF 3 > groups_3.txt containing program.pl, two files (input.txt, output.txt) and getting output in groups_3.txt: But, I wish to have 30 files corresponding to each CUTOFF ranging from 0 to 30 using the same... (1 Reply)
Discussion started by: bioinfo
1 Replies

8. UNIX for Dummies Questions & Answers

awk Grouping and Subgrouping with Counts

So I have a ton of files, lines in excess of 3 MIL per file. I need to find a solution to find the top 3 products, and then get the top 5 skews with a count of how many times that skew was viewed. This is a sample file, shortened it for readability. Each ROW is counted as view. Here's the... (10 Replies)
Discussion started by: JoshCrosby
10 Replies

9. Shell Programming and Scripting

Name grouping

awk 'FNR==NR {a; next} $NF in a' genes.txt refseq_exons.txt > output.txt I can not figure out how to group the same name in $4 together. Basically, all the SKI together in separate rows and all the TGFB2. Thank you :). chr1 2160133 2161174 SKI chr1 218518675 218520389 TGFB2... (1 Reply)
Discussion started by: cmccabe
1 Replies

10. Shell Programming and Scripting

Help with grouping and zipping

Hi can you please help with the below ? source file: Column1,Column2,Column3,Column4 abc,123,dir1/FXX/F19,1 abc,123,dir1/FXX/F20,1 abc,123,dir1/FXX/F23,2 abc,123,dir1/FXX/C25,2 abc,123,dir1/FXX/X25,2 abc,123,dir1/FXX/A23,3 abc,123,dir1/FXX/Z25,3 abc,123,dir1/FXX/Y25,4 I want to... (3 Replies)
Discussion started by: paul1234
3 Replies
acctcom(8)						      System Manager's Manual							acctcom(8)

NAME
acctcom - Displays selected process accounting record summaries SYNOPSIS
/usr/bin/acctcom [-abfhikmqrtv] [-C seconds] [-e time] [-E time] [-g group] [-H factor] [-I number] [-l line] [select_flag -o file] [-n pattern] [-O seconds] [-s time] [-S time] [-u username] [file ...] FLAGS
Displays average statistics about the selected processes. Statistics are displayed at the end of the output records in the format var=# (for example, CMDS=439), where the value (#) is given to the nearest hundredth. The var specifies the following: Value Total number of commands listed in the specified file Average real time per process Average CPU time per process Average user CPU time per process Average system CPU time per process Average number of characters transferred Average number of blocks transferred Average CPU factor (average user time divided by total CPU time) Average hog factor (average CPU time divided by average elapsed time) Displays information about the most recently executed commands first. This flag has no effect when the acctcom command reads from the default input device or if more than one process accounting file is specified. The column heading format is the same as the default column heading format. Lists processes whose total CPU time (system time + user time) is greater than the value specified by seconds. The column heading format is the same as the default column heading format. Displays information only about processes that start at or before the specified time, which is specified as hh[:mm[:ss]]. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy START BEFORE: day mon date hh:mm:ss yy COMMAND START END REAL CPU MEAN NAME USER TTYNAME TIME TIME (SECS) (SECS) SIZE(K) Displays information only about processes that end at or before the specified time, which is specified as hh[:mm[:ss]]. If you specify the same time for both the -E and -S flags, the acctcom command displays processes that existed at the specified time. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy END BEFORE : day mon date hh:mm:ss yy COMMAND START END REAL CPU MEAN NAME USER TTYNAME TIME TIME (SECS) (SECS) SIZE(K) Displays information about the fork/exec flag (used to execute another process) in the F column and the system exit value STAT, which can be zero (0) or an error code, in the STAT column in addition to the default column heading format. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy COMMAND START END REAL CPU MEAN NAME USER TTYNAME TIME TIME (SECS) (SECS) SIZE(K) F STAT Displays only the processes that belong to the specified group. You may specify either the group ID or the group name. The column heading format is the same as the default column heading format. Displays the hog factor instead of the mean memory size. The hog factor is the CPU time used by the process divided by the real time. The output is the same as the default column format output except the MEAN SIZE(K) column heading is replaced by the .HOG FACTOR heading. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy COMMAND START END REAL CPU HOG NAME USER TTYNAME TIME TIME (SECS) (SECS) FACTOR Displays information about processes that exceed the value specified by the hogfactor variable. The output format is the same as the default column heading format. Displays the number of characters and blocks transferred during read or write I/O operations. The output is similar to the default column heading format, except the CHARS TRANSFD column replaces the MEAN SIZE(K) column, and the BLOCKS READ column is added to the output. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy COMMAND START END REAL CPU CHARS BLOCKS NAME USER TTYNAME TIME TIME (SECS) (SECS) TRANSFD READ Displays information about the processes that transfer more than the number of characters specified by the number variable. The output format is the same as the default column heading format. Displays the total number of K-core min- utes, which is the number of kilobytes of memory used by the process multiplied by the buffer time used. The output format is the same as the default column heading format, except the KCORE MIN column heading replaces the MEAN SIZE(K) column heading. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy COMMAND START END REAL CPU KCORE NAME USER TTYNAME TIME TIME (SECS) (SECS) MIN Displays information about the processes that belong to the workstation whose tty line is specified by the line variable (for example, ttyp0). The heading format is the same as the default column heading format. Displays the median amount of process memory used. If you also specify the -h or -k flag, the -m flag is ignored. The output format is the same as the default column heading format. Displays information only about the processes whose names include the regular expression specified by the pattern variable. The output format is the same as the default column heading format. Copies selected process records to the specified filename. The select_flag variable specifies the following process selection flags: -C, -e, -E, -g, -H, -I, -l, -n, -O, -s, -S, and -u. If you do not specify a selection flag with the select_flag variable, all process records are copied to filename. The output format includes only the date and time: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy Displays information about the processes that have a CPU system time exceeding the time specified by the seconds variable. The output format is the same as the default column heading format. Displays only the average statistics, which are shown at the end of the command output when you use the -a flag. Displays the CPU factor, which is the user time divided by the total CPU time. The output format is the same as the default column heading format, except the CPU FACTOR column replaces the MEAN SIZE(K) column. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy COMMAND START END REAL CPU CPU NAME USER TTYNAME TIME TIME (SECS) (SECS) FACTOR Displays information about the processes that existed on or after time, which is specified as hh[:mm[:ss]]. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy END AFTER : day mon date hh:mm:ss yy COMMAND START END REAL CPU MEAN NAME USER TTYNAME TIME TIME (SECS) (SECS) SIZE(K) Displays information only about the processes that started at or after time, which is specified as hh[:mm[:ss]]. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy START AFTER : day mon date hh:mm:ss yy COMMAND START END REAL CPU MEAN NAME USER TTYNAME TIME TIME (SECS) (SECS) SIZE(K) Displays system and user CPU times under separate column headings. The CPU SYS column heading, which shows the system CPU time, replaces the CPU (SECS) default column heading. The column heading format is as follows: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yy COMMAND START END REAL CPU (SECS) NAME USER TTYNAME TIME TIME (SECS) SYS USER Displays information about the processes that are owned by user username. You can specify a user identification number, a login name converted to a user identification number, a number sign (#) to specify root or a question mark (?), which selects pro- cesses associated with unknown user identification numbers. The output format is the same as the default column heading format. Removes column headings from the output; otherwise the output is the same as the default column heading format. DESCRIPTION
The acctcom command displays process accounting records from files specified by the file parameter, from standard input, or from the /var/adm/pacct file. If you do not specify a file and if standard input is assigned to a workstation or to /dev/null (for example, if a process runs in the background), the acctcom command reads the /var/adm/pacct file. You do not have to be root to use the acctcom command, which is located in the /usr/bin directory. If you specify more than one filename, the acctcom process reads each file chronologically in time-descending order according to process completion time. Usually, the /var/adm/pacct file is used, but you can have several /var/adm/pacct/*Vn files, which are created by the ckpacct command. Each record specifies the execution times for a completed process. The default output format includes the command name, user name, tty name, process start time, process end time, real seconds, CPU seconds, and mean memory size (in kilobytes). The process summary output has the following default column heading format: ACCOUNTING RECORDS FROM: day mon date hh:mm:ss yyyy COMMAND START END REAL CPU MEAN NAME USER TTYNAME TIME TIME (SECS) (SECS) SIZE(K) If a specified time is later than the current time, it is interpreted as occurring on the previous day. You can use flags to display the state of the fork/exec flag, F column; the system exit value, STAT column; the ratio of total CPU time to elapsed time, HOG FACTOR column; the product of memory used and elapsed time, KCORE MIN column; the ratio of user time to total (system plus user) time, CPU FACTOR column; the number of characters transferred during I/O operations, CHARS TRNSFD column; and the total number of blocks read or written, BLOCKS READ column. If a process is run under root or su authority, the command name is prefixed with a number sign (#). If a process is not assigned to a known tty (for example, if the cron daemon runs the process), a question mark (?) is displayed in the TTYNAME column. The acctcom command reports only on processes that have completed. Use the ps command to examine the status of active processes. For any flag value that produces a timestamp in an output heading, the order of date and time information is locale dependent. The time- stamps shown in the examples use the default format for date and time values. EXAMPLES
The following command displays information about processes that exceed 2.0 seconds of CPU time: /usr/sbin/acct/acctcom -O 2 < /var/adm/pacct The following command displays information about processes belonging to the Finance group: /usr/sbin/acct/acctcom -g Finance < /var/adm/pacct The following command displays information about processes belonging to tty /dev/console that run after 5:00 p.m.: /usr/sbin/acct/acctcom -l /dev/console -s 17:00 FILES
Specifies the command path. The active process accounting database file. User and group database files. Accounting header files that define formats for writing accounting files. RELATED INFORMATION
Commands: ed(1), ps(1), su(1), acct(8), cron(8), runacct(8) Functions: acct(2) delim off acctcom(8)
All times are GMT -4. The time now is 01:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy