Sponsored Content
Top Forums Shell Programming and Scripting awk to sum specific field when pattern matches Post 302454523 by ux4me on Saturday 18th of September 2010 04:51:25 PM
Old 09-18-2010
Found the answer:
Code:
awk '{ if ( $2 == "UOWWAIT" ) { wait+=$6 ; } else { nowait+=$6 ; } } END { print wait " " nowait }'



---------- Post updated at 03:35 PM ---------- Previous update was at 03:35 PM ----------

thanks Bartus11.. that was super quick!

---------- Post updated at 03:51 PM ---------- Previous update was at 03:35 PM ----------

now i m trying to take another step to ensure that the "wait" connection does not belong to SAPR3 userid. i tried this syntax:

Code:
awk '{ if ( $2 == "UOWWAIT" && $4 != "SAPR3" ) { wait+=$6 ; } else { nowait+=$6 ; } } END { print wait "_" nowait }'

output:
Code:
2 31

instead of:
Code:
1 31

Please advise on the syntax. Thanking you in advance.

Moderator's Comments:
Mod Comment Use code tags, please.

Last edited by Scott; 09-18-2010 at 05:57 PM.. Reason: Please use CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to count pattern matches

i have an awk statement which i am using to count the number of occurences of the number ,5, in the file: awk '/,5,/ {count++}' TRY.txt | awk 'END { printf(" Total parts: %d",count)}' i know there is a total of 10 matches..what is wrong here? thanks (16 Replies)
Discussion started by: npatwardhan
16 Replies

2. Shell Programming and Scripting

Print line if first Field matches a pattern

Hi All, I would like my code to be able to print out the whole line if 1st field has a dot in the number. Sample input and expected output given below. My AWK code is below but it can;t work, can any expert help me ? Thanks in advance. {if ($1 ~ /*\.*/) { print $0 }} Input: ... (2 Replies)
Discussion started by: Raynon
2 Replies

3. Shell Programming and Scripting

Displaying lines of a file where the second field matches a pattern

Howdy. I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited? Example: You are... (3 Replies)
Discussion started by: LordJezoX
3 Replies

4. Shell Programming and Scripting

NAWK to remove lines that matches a specific pattern

Hi, I have requirement that I need to split my input file into two files based on a search pattern "abc" For eg. my input file has below content abc defgh zyx I need file 1 with abc and file2 with defgh zyx I can use grep command to acheive this. But with grep I need... (8 Replies)
Discussion started by: sbhuvana20
8 Replies

5. Shell Programming and Scripting

Displaying the first field if the second field matches the pattern using Perl

Hi, I am trying with the below Perl command to print the first field when the second field matches the given pattern: perl -lane 'open F, "< myfile"; for $i (<F>) {chomp $i; if ($F =~ /patt$/) {my $f = (split(" ", $i)); print "$f";}} close F' dummy_file I know I can achieve the same with the... (7 Replies)
Discussion started by: royalibrahim
7 Replies

6. Shell Programming and Scripting

Breaking the sum of a column when specific pattern is found

Hi Am trying to sum up a file # cat /Out maths 2 0.0 english 2091 0.2 history -1 0.0 physics 18 0.0 -------------------------------------- maths ... (9 Replies)
Discussion started by: Priya Amaresh
9 Replies

7. Shell Programming and Scripting

awk with range but matches pattern

To match range, the command is: awk '/BEGIN/,/END/' but what I want is the range is printed only if there is additional pattern that matches in the range itself? maybe like this: awk '/BEGIN/,/END/ if only in that range there is /pattern/' Thanks (8 Replies)
Discussion started by: zorrox
8 Replies

8. Shell Programming and Scripting

awk to output specific matches in file

Using the attached file, the below awk command results in the output below: I can not seem to produce the desired results and need some expert help. Thank you :). awk -F'' ' { id += $4 value += $5 occur++ } END{ printf "%-8s%8s%8s%8s\n", "Gene", "Targets", "Average Depth", "Average... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. Shell Programming and Scripting

awk to remove lines in file if specific field matches

I am trying to remove lines in the target.txt file if $5 before the - in that file matches sorted_list. I have tried grep and awk. Thank you :). grep grep -v -F -f targets.bed sort_list grep -vFf sort_list targets awk awk -F, ' > FILENAME == ARGV {to_remove=1; next} > ! ($5 in... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

awk to combine matches and use a field to adjust coordinates in other fields

Trying to output a result that uses the data from file to combine and subtract specific lines. If $4 matches in each line then the last $6 value is added to $2 and that becomes the new$3. Each matching line in combined into one with $1 then the original $2 then the new$3 then $5. For the cases... (4 Replies)
Discussion started by: cmccabe
4 Replies
NODE.PERMS(5)						     Linux Programmer's Manual						     NODE.PERMS(5)

NAME
node.perms - LinuxNode permissions file. DESCRIPTION
Node.perms file is read at program startup with the knowledge of users username (call), connection type (AX.25, NET/ROM, ROSE, TCP/IP), peers IP address (for TCP/IP) and port name (for AX.25). The first entry matching this information is taken and user is asked for password and given permissions according to it. The lines within node.perms must either be a comment line, which starts with a # in the first column, or a permission entry in the follow- ing format, each field being delimited by white space: username type portname password permissions The field descriptions are: username This is matched against users username (call) without SSID. An asterisk (*) matches any username. type This is matched against the type of the connection to user. Possible values for this field are: * matches any type of connection. ax25 matches users coming in with AX.25. netrom matches users coming in with NET/ROM. rose matches users coming in with ROSE. local matches TCP/IP connections where users host is in "local" network as defined in node.conf(5). ampr matches TCP/IP connections where users host is in amprnet (44.0.0.0/8). inet matches TCP/IP connections where users host is neither in "local" network nor in amprnet. host matches users starting LinuxNode from shell. portname If user is coming in with AX.25 this field is matched against the local port name the user is coming in via. An asterisk (*) matches any port name. password If the previous tree fields match and this field is not a single asterisk (*) the user is asked for a password. The password is then matched against this field. permissions This field represents a a bitmask of operations the user is permitted to do. It is a sum of the values listed here: 1 permits logging in even if no other permissions are given. 2 permits outgoing AX.25 connects. 4 permits outgoing NET/ROM connects. 8 permits telneting to hosts in the "local" network as defined in node.conf(5). 16 permits telneting to hosts in amprnet. 32 permits telneting to hosts neither in the "local" network nor in amprnet. 64 permits using hidden ports in outgoing AX.25 connections. (See HiddenPorts command in node.conf(5).) 128 permits outgoing ROSE connects. 256 The no-escape flag. Disables the escape mechanism for this user. FILES
/etc/ax25/node.perms SEE ALSO
node(8), node.conf(5), axports(5), ax25(4). Linux 16 June 1999 NODE.PERMS(5)
All times are GMT -4. The time now is 11:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy