Aggregate Boolean values using AND operation in Shell

7 views
Skip to first unread message

jabir m

unread,
Oct 14, 2014, 2:39:24 PM10/14/14
to unix-and-perl-...@googlegroups.com
Hi -
I have have file which contains Boolean values (true/false) based on 3 column..

I want to aggregate the file based on these 3 column using "AND" condition for Boolean values.

Below is the example for the input file and the required output file.
If I have TRUE in 4th column for the same A/B/C columns result should be TRUE and else it is FALSE.


Any one please give me hint to achieve this.

Thanks
Jabir

Input
A1 B1 C1 TRUE
A1 B1 C1 TRUE
A2 B1 C1 TRUE
A2 B1 C1 FALSE
A1 B2 C1 FALSE
A1 B2 C1 TRUE
output
A1 B1 C1 TRUE
A2 B1 C1 FALSE
A1 B2 C1 FALSE

raghvendra singh

unread,
Oct 15, 2014, 1:15:11 AM10/15/14
to unix-and-perl-...@googlegroups.com
you can easly do it by simply using uniq command in linux

uniq <ur input file.txt> >  <out_uniq.txt>

--
You received this message because you are subscribed to the Google Groups "Unix and Perl for Biologists" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unix-and-perl-for-bi...@googlegroups.com.
To post to this group, send email to unix-and-perl-...@googlegroups.com.
Visit this group at http://groups.google.com/group/unix-and-perl-for-biologists.
For more options, visit https://groups.google.com/d/optout.



--
------------------------------------------------------------------------------------------------------
Raghvendra Singh
  Center of Bioinformatics
  Nehru Science Center.
  IIDS.
  University of Allahabad.
  +91-9559019566

raghvendra singh

unread,
Oct 15, 2014, 1:17:55 AM10/15/14
to unix-and-perl-...@googlegroups.com
if want to count how many times redundant lines occur then just simply put -c after uniq

if you have further any query feel free to ask

jabir muhiyudheen

unread,
Oct 15, 2014, 3:03:40 AM10/15/14
to unix-and-perl-...@googlegroups.com

I hope you haven't understood the question. Uniq will work only for the condition two rows are equal,
In my example u can see I have two rows its 4th column is different

You received this message because you are subscribed to a topic in the Google Groups "Unix and Perl for Biologists" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/unix-and-perl-for-biologists/sLeFrx3L1ag/unsubscribe.
To unsubscribe from this group and all its topics, send an email to unix-and-perl-for-bi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages