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

This User Gave Thanks to bartus11 For This Post:
 

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
inetd.conf(4)                                                      File Formats                                                      inetd.conf(4)

NAME
inetd.conf - Internet servers database SYNOPSIS
/etc/inet/inetd.conf /etc/inetd.conf DESCRIPTION
In the current release of the Solaris operating system, the inetd.conf file is no longer directly used to configure inetd. The Solaris ser- vices which were formerly configured using this file are now configured in the Service Management Facility (see smf(5)) using inetadm(1M). Any records remaining in this file after installation or upgrade, or later created by installing additional software, must be converted to smf(5) services and imported into the SMF repository using inetconv(1M), otherwise the service will not be available. For Solaris operating system releases prior to the current release (such as Solaris 9), the inetd.conf file contains the list of servers that inetd(1M) invokes when it receives an Internet request over a socket. Each server entry is composed of a single line of the form: service-name endpoint-type protocol wait-status uid server-program server-arguments Fields are separated by either <SPACE> or <TAB> characters. A `#' (number sign) indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines that search this file. service-name The name of a valid service listed in the services file. For RPC services, the value of the service-name field con- sists of the RPC service name or program number, followed by a '/' (slash) and either a version number or a range of version numbers, for example, rstatd/2-4. endpoint-type Can be one of: stream for a stream socket dgram for a datagram socket raw for a raw socket seqpacket for a sequenced packet socket tli for all TLI endpoints protocol A recognized protocol listed in the file /etc/inet/protocols. For servers capable of supporting TCP and UDP over IPv6, the following protocol types are also recognized: tcp6 udp6 tcp6 and udp6 are not official protocols; accordingly, they are not listed in the /etc/inet/protocols file. Here the inetd program uses an AF_INET6 type socket endpoint. These servers can also handle incoming IPv4 client requests in addition to IPv6 client requests. For RPC services, the field consists of the string rpc followed by a '/' (slash) and either a '*' (asterisk), one or more nettypes, one or more netids, or a combination of nettypes and netids. Whatever the value, it is first treated as a nettype. If it is not a valid nettype, then it is treated as a netid. For example, rpc/* for an RPC service using all the transports supported by the system (the list can be found in the /etc/netconfig file), equiv- alent to saying rpc/visible rpc/ticots for an RPC service using the Connection-Oriented Transport Service. wait-status This field has values wait or nowait. This entry specifies whether the server that is invoked by inetd will take over the listening socket associated with the service, and whether once launched, inetd will wait for that server to exit, if ever, before it resumes listening for new service requests. The wait-status for datagram servers must be set to wait, as they are always invoked with the orginal datagram socket that will participate in delivering the service bound to the specified service. They do not have separate "listening" and "accepting" sockets. Accordingly, do not configure UDP services as nowait. This causes a race condition by which the inetd program selects on the socket and the server program reads from the socket. Many server programs will be forked, and performance will be severely compromised. Connection-oriented services such as TCP stream services can be designed to be either wait or nowait status. uid The user ID under which the server should run. This allows servers to run with access privileges other than those for root. server-program Either the pathname of a server program to be invoked by inetd to perform the requested service, or the value internal if inetd itself provides the service. server-arguments If a server must be invoked with command line arguments, the entire command line (including argument 0) must appear in this field (which consists of all remaining words in the entry). If the server expects inetd to pass it the address of its peer, for compatibility with 4.2BSD executable daemons, then the first argument to the command should be specified as %A. No more than 20 arguments are allowed in this field. The %A argument is implemented only for services whose wait-status value is nowait. FILES
/etc/netconfig network configuration file /etc/inet/protocols Internet protocols /etc/inet/services Internet network services SEE ALSO
rlogin(1), rsh(1), in.tftpd(1M), inetadm(1M), inetconv(1M), inetd(1M), services(4), smf(5) NOTES
/etc/inet/inetd.conf is the official SVR4 name of the inetd.conf file. The symbolic link /etc/inetd.conf exists for BSD compatibility. This man page describes inetd.conf as it was supported in Solaris operating system releases prior to the current release. The services that were configured by means of inetd.conf are now configured in the Service Management Facility (see smf(5)) using inetadm(1M). SunOS 5.10 17 Dec 2004 inetd.conf(4)
All times are GMT -4. The time now is 03:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy