Sponsored Content
Top Forums Shell Programming and Scripting Data filtering and category assigning Post 302929089 by jianp83 on Wednesday 17th of December 2014 03:06:42 PM
Old 12-17-2014
Hello Praveen, thank you for the solution. However there might be some problem. The number of rows returned is much less than what is in the input



Code:
 $ cat prav
Group77 T1      AA      Snum048PX-02052
Group77 T2      GG      Snum060PX-02118
Group77 T1*T2   AA      Snum046PX-03072
Group77 T1*T2   AA      Snum048PX-00003
Group77 T1*T2   AA      Snum048PX-00008
Group77 T1*T2   AA      Snum048PX-00010
Group77 T1*T2   AA      Snum048PX-00014
Group77 T1*T2   AA      Snum048PX-00015
Group77 T1*T2   AA      Snum048PX-00016
Group77 T1*T2   AA      Snum048PX-00019

perl prav.pl prav
Group77 T1*T2   AA      Snum048PX-00014 T1-like
Group77 T1*T2   AA      Snum048PX-00008 T1-like
Group77 T1*T2   AA      Snum048PX-00016 T1-like
Group77 T1*T2   AA      Snum048PX-00003 T1-like

Hello Rudi,

For the following set of data no output should be produced since T1 and T2 values are same. Would you please look into this problem?

Code:
$ cat  rudi
Group78 T1      AA      Snum048PX02065
Group78 T2      AA      Snum060PX02052
Group78 T1*T2   AA      Snum048PX02068
Group78 T1*T2   AA      Snum048PX02069
Group78 T1*T2   AA      Snum048PX02070
Group78 T1*T2   AG      Snum048PX02093


$ awk     'NR==FNR        {if ($2 !~/\*/) {L[$1,$2]=$3
>                                          G[$1]++
>                                          T[$2]}
>                          next}
>          $2 ~ /\*/      {C=0
>                          K="diff"
>                          for (i in T) if (L[$1,i] == $3) {C++; K=i}
>                          if (C<2 && G[$1]>=2) print $0, K
>                         }
>         ' SUBSEP="," OFS="\t" rudi rudi 
Group78 T1*T2   AG      Snum048PX02093  diff

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Filtering out data ...

I have following command which tells me File size in GBs which are greater than 0.01GBs recursively in a dir structure. ls -l -R | awk '{ if ($5/1073741824 >= 0.01) print $9, $5/1073741824 }' But there are some files whom I dont have enough permissions, after executing this script gives me... (1 Reply)
Discussion started by: videsh77
1 Replies

2. Shell Programming and Scripting

Filtering Data

Hi All, I have the below input and expected ouput. I need a code which can scan through this input file and if the number in column1 is more than 1 , it will print out the whole line, else it will output "No Re-occurrence". Can anybody help ? Input: 1 vvvvv 20 7 7 23 0 64 6 zzzzzz 11 5... (7 Replies)
Discussion started by: Raynon
7 Replies

3. UNIX for Dummies Questions & Answers

Filtering Data

file1 contain: (this just a small sample of data it may have thousand of lines) 1 aaa 1/01/1975 delhi 2 bbb 2/03/1977 mumbai 3 ccc 1/01/1975 mumbai 4 ddd 2/03/1977 chennai 5 aaa 1/01/1975 kolkatta 6 bbb 2/03/1977 bangalore program: nawk '{ idx= $2 SUBSEP $3 arr = (idx in arr) ?... (2 Replies)
Discussion started by: bobo
2 Replies

4. Shell Programming and Scripting

help need in filtering data

Hello Gurus, Please help me out of the problem. I ve a input file as below input clock; input a; //reset all input b; //input comment output c; output d; output e; input f; //output comment I need the output as follows: \\Inputs (1 Reply)
Discussion started by: user_prady
1 Replies

5. Shell Programming and Scripting

Parsing out the first (top) data lines of each category

Hi All, I need some help in parsing out the first (top) data lines of each category (categories are based on the first column a, b, c, d, e.( see example file below) from a big file a dfg 3 6 8 9 a fgh 5 7 0 9 a gkl 5 2 4 7 a glo 7 0 1 5 b ghj 9 0 4 2 b mkl 7 8 0 5 b jkl 9 0 4 5 c jkl 2... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

6. Shell Programming and Scripting

Filtering data using AWK

Hi , i have file with delimiter as "|" and data in Double codes for all fields. how to filter data in a column like awk -F"|" '$1="asdf" {print $0}' test. ex : "asdf"|"zxcv" Thanks, Soma (1 Reply)
Discussion started by: challamsomu
1 Replies

7. Shell Programming and Scripting

awk data filtering

I am trying to filter out some data with awk. If someone could help me that would be great. Below is my input file. Date: 10-JUN-12 12:00:00 B 0: 00 00 00 00 10 00 16 28 B 120: 00 00 00 39 53 32 86 29 Date: 10-JUN-12 12:00:10 B 0: 00 00 00 00 10 01 11 22 B 120: 00 00 00 29 23 32 16 29... (5 Replies)
Discussion started by: thibodc
5 Replies

8. Shell Programming and Scripting

Filtering out the data with dates

Hi, I have some data like seen below. format : apple(hhmm mm/dd).fruit apple(2345 03/25).fruit apple(2345 05/06).fruit orange(0443 05/02).fruit orange(0345 05/05).fruit orange(2134 05/04).fruit grape(0930 04/24).fruit grape(2330 03/30).fruit I need to get the data which are... (1 Reply)
Discussion started by: jayadanabalan
1 Replies

9. Shell Programming and Scripting

Need help Filtering Data from an API

Hi Everyone, I need help on figuring out a way to filter some data that I get back from an API. Im able to get all the data that Im looking for but I would like to know a way for me to filter it better. The data that Im getting back is basically 2 rows of data as seen here. Row 1 ... (25 Replies)
Discussion started by: TheStruggle
25 Replies

10. Shell Programming and Scripting

Inserting column data based on category assignment

please help with the following. I have 4 col data .. instrument , category, variable and value. the instruments belong to particular categories and they all measure some variables (var1 and var2 in this example), the last column is the value an instrument outputs for a variable. I have used... (0 Replies)
Discussion started by: ritakadm
0 Replies
GROUPS(1)                                                          User Commands                                                         GROUPS(1)

NAME
groups - print the groups a user is in SYNOPSIS
groups [OPTION]... [USERNAME]... DESCRIPTION
Print group memberships for each USERNAME or, if no USERNAME is specified, for the current process (which may differ if the groups database has changed). --help display this help and exit --version output version information and exit AUTHOR
Written by David MacKenzie and James Youngman. REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report groups translation bugs to <http://translationproject.org/team/> COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
getent(1) Full documentation at: <http://www.gnu.org/software/coreutils/groups> or available locally via: info '(coreutils) groups invocation' GNU coreutils 8.28 January 2018 GROUPS(1)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy