Sponsored Content
Top Forums Shell Programming and Scripting awk to count condition in field Post 302962171 by Aia on Wednesday 9th of December 2015 10:31:12 AM
Old 12-09-2015
Would that work?
Code:
awk '$8 ~ /TYPE/ {split($8, type, "="); count[type[2]]++} END{for(t in count){print t"="count[t]}}' "C:\Users\cmccabe\Desktop\counts\TSVC_004_HIQ.txt" > "C:\Users\cmccabe\Desktop\counts\count.txt"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk-Group count of field

Hi, Suppose if i am having a file with following records as given below. 5555 6756 5555 4555 4555 6767 how can i get the count of each record using AWK. Eg:5555 count should be 2 4555 count should be 2 6767 count should be 1 ... (5 Replies)
Discussion started by: tinivt
5 Replies

2. Shell Programming and Scripting

Help with Awk finding and replacing a field based on a condition

Hi everybody, I'm trying to replace the $98 field with "T" if the last field (108th) is T I've tried awk 'BEGIN{OFS=FS="|"} {if ($108=="T")sub($98,"T"); print}' test.txt but that doesn't do anything also tried awk 'BEGIN{OFS=FS="|"}{ /*T.$/ sub($98,"T")} { print}' test.txt but... (2 Replies)
Discussion started by: jghi123
2 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Awk: count occurrence of each character for every field

Hi, let's say an input looks like: A|C|C|D A|C|I|E A|B|I|C A|T|I|B as the title of the thread explains, I am trying to get something like: 1|A=4 2|C=2|B=1|T=1 3|I=3|C=1 4|D=1|E=1|C=1|B=1 i.e. a count of every character in each field (first column of output) independently, sorted... (4 Replies)
Discussion started by: beca123456
4 Replies

4. Shell Programming and Scripting

awk to replace a specific field in certain condition

Hi, I have a file like below PRUM,67016800 ,CC ,C1,67016800 , ,Y,Y,2 ,CK,BX,FOX ,00000001,EA,00000001,20141120 00:00:00, ,N,Y,Y,CK ABCDEF... (7 Replies)
Discussion started by: mady135
7 Replies

5. Shell Programming and Scripting

awk joining multiple lines based on field count

Hi Folks, I have a file with fields as follows which has last field in multiple lines. I would like to combine a line which has three fields with single field line for as shown in expected output. Please help. INPUT hname01 windows appnamec1eda_p1, ... (5 Replies)
Discussion started by: shunya
5 Replies

6. Shell Programming and Scripting

awk to remove lines where field count is greather than 1 in two fields

I am trying to remove all the lines and spaces where the count in $4 or $5 is greater than 1 (more than 1 letter). The file and the output are tab-delimited. Thank you :). file X 5811530 . G C NLGN4X 17 10544696 . GA G MYH3 9 96439004 . C ... (1 Reply)
Discussion started by: cmccabe
1 Replies

7. Shell Programming and Scripting

awk to change contents of field based on condition in same file

In the awk below I am trying to copy the entire contents of $6 there may be multiple values seperated by a ;, to $8, if $8 is . (lines 1 and 3 are examples). If that condition $8 is not . (line2 is an example) then that line is skipped and printed as is. The awk does execute but prints the output... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Shell Programming and Scripting

awk to adjust text and count based on value in field

The below awk executes as is and produces the current output. It isvery close but what Ican not seem to do is add the -exon..., the ... portion comes from $1 and the _exon is static and will never change. If there is + sign in $4 then the ... is in acending order or sequential. If there is a - in... (2 Replies)
Discussion started by: cmccabe
2 Replies

9. UNIX for Beginners Questions & Answers

Awk: count unique elements in a field and sum their occurence across the entire file

Hi, Sure it's an easy one, but it drives me insane. input ("|" separated): 1|A,B,C,A 2|A,D,D 3|A,B,B I would like to count the occurence of each capital letters in $2 across the entire file, knowing that duplicates in each record count as 1. I am trying to get this output... (5 Replies)
Discussion started by: beca123456
5 Replies

10. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
Ace::Sequence::FeatureList(3pm) 			User Contributed Perl Documentation			   Ace::Sequence::FeatureList(3pm)

NAME
Ace::Sequence::FeatureList - Lightweight Access to Features SYNOPSIS
# get a megabase from the middle of chromosome I $seq = Ace::Sequence->new(-name => 'CHROMOSOME_I, -db => $db, -offset => 3_000_000, -length => 1_000_000); # find out what's there $list = $seq->feature_list; # Scalar context: count all the features $feature_count = $list->types; # Array context: list all the feature types @feature_types = $list->types; # Scalar context, 1 argument. Count this type $gene_cnt = $list->types('Predicted_gene'); print "There are $gene_cnt genes here. "; # Array context, 1 argument. Get list of subtypes @subtypes = $list->types('Predicted_gene'); # Two arguments. Count type & subtype $genefinder_cnt = $list->types('Predicted_gene','genefinder'); DESCRIPTION
Ace::Sequence::FeatureList is a small class that provides statistical information about sequence features. From it you can obtain summary counts of the features and their types within a selected region. OBJECT CREATION
You will not ordinarily create an Ace::Sequence::FeatureList object directly. Instead, objects will be created by calling a Ace::Sequence object's feature_list() method. If you wish to create an Ace::Sequence::FeatureList object directly, please consult the source code for the new() method. OBJECT METHODS
There are only two methods in Ace::Sequence::FeatureList. type() This method has five distinct behaviors, depending on its context and the number of parameters. Usage should be intuitive Context Arguments Behavior ------- --------- -------- scalar -none- total count of features in list array -none- list feature types (e.g. "exon") scalar type count features of this type array type list subtypes of this type -any- type,subtype count features of this type & subtype For example, this code fragment will count the number of exons present on the list: $exon_count = $list->type('exon'); This code fragment will count the number of exons found by "genefinder": $predicted_exon_count = $list->type('exon','genefinder'); This code fragment will print out all subtypes of "exon" and their counts: for my $subtype ($list->type('exon')) { print $subtype," ",$list->type('exon',$subtype)," "; } asString() print $list->asString; This dumps the list out in tab-delimited format. The order of columns is type, subtype, count. SEE ALSO
Ace, Ace::Object, Ace::Sequence, Ace::Sequence::Feature, GFF AUTHOR
Lincoln Stein <lstein@w3.org> with extensive help from Jean Thierry-Mieg <mieg@kaa.crbm.cnrs-mop.fr> Copyright (c) 1999, Lincoln D. Stein This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty. perl v5.14.2 2000-06-11 Ace::Sequence::FeatureList(3pm)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy