Sponsored Content
Top Forums Shell Programming and Scripting Counting specific column and add result in output Post 302869771 by owwow14 on Thursday 31st of October 2013 07:09:57 AM
Old 10-31-2013
Counting specific column and add result in output

Hi all,
I have a quick question:
I have a 4 column tab-separated file.
I want to count the number of times each unique value in column 2 appears and add that number in a 5th column.

I have the following input file:

Code:
waterline-n    below-sheath-v    14.8097    A
dock-n    below-sheath-v     14.5095    B
waterline-n    below-steel-n    11.0330    A
picnic-n    below-steel-n    12.2277    C
wavefront-n    at-part-of-variance-n    18.4888    L
wavefront-n    between-part-of-variance-n    17.0656    A
audience-b    between-part-of-variance-n    17.6346    B
game-n    between-part-of-variance-n    14.9652    C
whereabouts-n    become-rediscovery-n    11.3556    L
whereabouts-n    get-tee-n    10.9091    L


and the following is the desired output

Code:
waterline-n    below-sheath-v    14.8097    A   2
dock-n    below-sheath-v     14.5095    B   2
waterline-n    below-steel-n    11.0330    A   2
picnic-n    below-steel-n    12.2277    C   2
wavefront-n    at-part-of-variance-n    18.4888    L   1
wavefront-n    between-part-of-variance-n    17.0656    A   3
audience-b    between-part-of-variance-n    17.6346    B   3
game-n    between-part-of-variance-n    14.9652    C   3
whereabouts-n    become-rediscovery-n    11.3556    L   1
whereabouts-n    get-tee-n    10.9091    L  1

How can I combine sort and grep for the desired output?
Thank you.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Counting occurences of specific charachter in a file

Hi, I need to count the number of occurences of the character " in a file that contains huge number of records. What command could I use? Please specify in detail since I am new :| Thanks much. (3 Replies)
Discussion started by: GMMike
3 Replies

2. UNIX for Dummies Questions & Answers

egrep counting every 2 lines of result as 1

Hi, Can someone help me count this line: Say I have a file (file1.txt) that contains below: 11/16 13:08:19.5436 18096 --- Generating a <reading> event 11/16 13:08:19.7784 18096 ---- Sending a <writing> event 11/16 13:08:37.4516 18096 --- Generating a <reading> event 11/16... (1 Reply)
Discussion started by: Orbix
1 Replies

3. Shell Programming and Scripting

Counting the differences based on a specific rule

Hi, I've been trying to create a perl file to run something very specific. But I'm not getting any success. I'm not very good with hashing. I have a file with two columns (tab separated) (already sorted) 99890 + 100281 + 104919 - 109672 + 113428 - 114501 + 115357 + 115598 ... (7 Replies)
Discussion started by: labrazil
7 Replies

4. Shell Programming and Scripting

4 column tsv file, output 1 specific column

Hello all siteexplorer.search.yahoo.com can output results in tsv format, when opened in excel I get 4 columns. I would like to wget that file, which I can do. I would then like to pull the 2nd column and output it only. I've searched around and found a few bits and pieces but nothing I've... (6 Replies)
Discussion started by: casphar
6 Replies

5. Shell Programming and Scripting

Counting rows line by line from a specific column using Awk

Dear UNIX community, I would like to to count characters from a specific row and have them displayed line-by-line. I have a file called testAwk2.csv which contain the following data: rabbit penguin goat giraffe emu ostrich I would like to count in the middle row individually... (4 Replies)
Discussion started by: vnayak
4 Replies

6. Shell Programming and Scripting

Counting specific words from the log

Hi, I need a shell script which can provide details from error logs like this Aug 23 21:19:41 red mountd: authenticated mount request from bl0110.bang.m pc.local:651 for /disk1/jobs (/disk1) Aug 23 08:49:52 red dhcpd: DHCPDISCOVER from 00:25:90:2b:cd:7c via eth0: unknown client Aug 24... (2 Replies)
Discussion started by: ratheeshp
2 Replies

7. Shell Programming and Scripting

Counting non-specific occurrences within a file.

I'm pretty new to scripting and didn't see an example of this issue yet. I am trying to count and print the total number of times each value is found within a file. Here is a short example of my starting file. value 3 value 3 value 3 value 3 value 4 value 6 value 6 value 6 value 6... (3 Replies)
Discussion started by: funkynmr
3 Replies

8. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

9. UNIX for Beginners Questions & Answers

Add column and multiply its result to all elements of another column

Input file is as follows: 1 | 6 2 | 7 3 | 8 4 | 9 5 | 10 Output reuired (sum of the first column $1*$2) 1 | 6 | 90 2 | 7 | 105 3 | 8 | 120 4 |9 | 135 5 |10 | 150 Please enclose sample input, sample output, and code... (5 Replies)
Discussion started by: Sagar Singh
5 Replies
MPSCNNLocalContrastNormalization(3)			 MetalPerformanceShaders.framework		       MPSCNNLocalContrastNormalization(3)

NAME
MPSCNNLocalContrastNormalization SYNOPSIS
#import <MPSCNNNormalization.h> Inherits MPSCNNKernel. Instance Methods (nonnull instancetype) - initWithDevice:kernelWidth:kernelHeight: (nullable instancetype) - initWithCoder:device: (nonnull instancetype) - initWithDevice: Properties float alpha float beta float delta float p0 float pm float ps NSUInteger kernelWidth NSUInteger kernelHeight Additional Inherited Members Detailed Description This depends on Metal.framework Specifies the local contrast normalization filter. The local contrast normalization is quite similar to spatial normalization (see MPSCNNSpatialNormalization) in that it applies the filter over local regions which extend spatially, but are in separate feature channels (i.e., they have shape 1 x kernelWidth x kernelHeight), but instead of dividing by the local 'energy' of the feature, the denominator uses the local variance of the feature - effectively the mean value of the feature is subtracted from the signal. For each feature channel, the function computes the variance VAR(i,j) and mean M(i,j) of X(i,j) inside each rectangle around the spatial point (i,j). Then the result is computed for each element of X as follows: Y(i,j) = pm + ps * ( X(i,j) - p0 * M(i,j)) / (delta + alpha * VAR(i,j))^beta, where kw and kh are the kernelWidth and the kernelHeight and pm, ps and p0 are parameters that can be used to offset and scale the result in various ways. For example setting pm=0, ps=1, p0=1, delta=0, alpha=1.0 and beta=0.5 scales input data so that the result has unit variance and zero mean, provided that input variance is positive. It is the end-users responsibility to ensure that the combination of the parameters delta and alpha does not result in a situation where the denominator becomes zero - in such situations the resulting pixel-value is undefined. A good way to guard against tiny variances is to regulate the expression with a small value for delta, for example delta = 1/1024 = 0.0009765625. Method Documentation - (nullable instancetype) initWithCoder: (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device NSSecureCoding compatability While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use initWithCoder:device instead. Parameters: aDecoder The NSCoder subclass with your serialized MPSKernel device The MTLDevice on which to make the MPSKernel Returns: A new MPSKernel object, or nil if failure. Reimplemented from MPSCNNKernel. - (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device Standard init with default properties per filter type Parameters: device The device that the filter will be used on. May not be NULL. Returns: A pointer to the newly initialized object. This will fail, returning nil if the device is not supported. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later. Reimplemented from MPSCNNKernel. - (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device(NSUInteger) kernelWidth(NSUInteger) kernelHeight Initialize a local contrast normalization filter Parameters: device The device the filter will run on kernelWidth The width of the kernel kernelHeight The height of the kernel Returns: A valid MPSCNNLocalContrastNormalization object or nil, if failure. NOTE: For now, kernelWidth must be equal to kernelHeight Property Documentation - alpha [read], [write], [nonatomic], [assign] The value of alpha. Default is 0.0 The default value 0.0 is not recommended and is preserved for backwards compatibility. With alpha 0, it performs a local mean subtraction. The MPSCNNLocalContrastNormalizationNode used with the MPSNNGraph uses 1.0 as a default. - beta [read], [write], [nonatomic], [assign] The value of beta. Default is 0.5 - delta [read], [write], [nonatomic], [assign] The value of delta. Default is 1/1024 - kernelHeight [read], [nonatomic], [assign] The height of the filter window - kernelWidth [read], [nonatomic], [assign] The width of the filter window - p0 [read], [write], [nonatomic], [assign] The value of p0. Default is 1.0 - pm [read], [write], [nonatomic], [assign] The value of pm. Default is 0.0 - ps [read], [write], [nonatomic], [assign] The value of ps. Default is 1.0 Author Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code. Version MetalPerformanceShaders-100 Thu Feb 8 2018 MPSCNNLocalContrastNormalization(3)
All times are GMT -4. The time now is 11:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy