Answers.Body: <p>I would do something like this:</p>
  <pre><code>$ cat test.tsv 
  groupA  1       1       1       0       0       0
  groupB  1       1       0       0       0       0
  groupC  1       0       1       0       0       0
  groupD  1       1       1       0       0       0
  groupE  0       0       0       1       1       1
  groupF  0       0       0       1       1       0
  
  <span class="math-container">$ awk '($</span>5==1 &amp;&amp; <span class="math-container">$6==1 &amp;&amp; $</span>2+<span class="math-container">$3+$</span>4+<span class="math-container">$7==0){print $</span>1}'
  groupF
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-19T22:12:03.080Z
Answers.Text: Thank you it worked
Answers.UserDisplayName: ambika
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-19T21:36:44.713Z
Answers.LastActivityDate: 2021-11-19T21:36:44.713Z
Answers.UserDisplayName: vkkodali
Answers.Body: <p>Straightforwardly</p>
  <pre class="lang-sh prettyprint-override"><code>awk '$2==0 &amp;&amp; $3==0 &amp;&amp; $4==0 &amp;&amp; $5==1 &amp;&amp; $6==1 &amp;&amp; $7==0 {print $1}' bin.file
  </code></pre>
  <p>A little spiffier</p>
  <pre class="lang-sh prettyprint-override"><code>awk '$5 &amp;&amp; $6 &amp;&amp; !($2 || $3 || $4 || $7) {print $1}' bin.file
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-19T22:12:09.230Z
Answers.Text: Thank you it worked
Answers.UserDisplayName: ambika
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-19T21:34:20.717Z
Answers.LastActivityDate: 2021-11-19T21:34:20.717Z
Answers.UserDisplayName: glenn jackman
Body: <p>I have a binary file which looks like this,</p>
  <pre><code>Orthogroup  A   B   C   D   E   F
  OG0000000   1   1   1   0   0   0
  OG0000001   1   1   1   0   0   0
  OG0000002   1   1   1   0   0   0
  OG0000003   1   1   1   0   0   0
  OG0000004   0   0   0   1   1   0
  OG0000005   0   0   0   1   1   0
  OG0000006   0   0   0   1   1   0
  OG0000007   0   0   0   1   1   0
  OG0000008   1   0   0   0   0   0
  OG0000009   1   0   0   0   0   0
  OG0000010   1   0   0   0   0   0
  </code></pre>
  <p>I want to use awk to print the first column if column D and E is 1 and rest is 0.</p>
  <pre><code>OG0000004
  OG0000005
  OG0000006
  OG0000007
  </code></pre>
  <p>I tried to do this with individual files of each column  using the awk command</p>
  <pre><code>awk 'NR==FNR{arr[<span class="math-container">$0];next} $</span>0 in arr' file1 file2 
  </code></pre>
  <p>but doing this I had to generate multiple files and I thought using a binary file will be a more clean way.</p>
  <p>Please Help,</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-19T21:31:07.117Z
Comments.Text: It would be more helpful to paste the actual text instead of pictures of it.
Comments.UserDisplayName: glenn jackman
Tags: <linux><awk>
Title: Print first colum is the condition is true using awk
ThreadText: # Print first colum is the condition is true using awk
  
  (Asked by: username_0 on 2021-11-19)
  
  I have a binary file which looks like this,
  
  ```
  Orthogroup  A   B   C   D   E   F
  OG0000000   1   1   1   0   0   0
  OG0000001   1   1   1   0   0   0
  OG0000002   1   1   1   0   0   0
  OG0000003   1   1   1   0   0   0
  OG0000004   0   0   0   1   1   0
  OG0000005   0   0   0   1   1   0
  OG0000006   0   0   0   1   1   0
  OG0000007   0   0   0   1   1   0
  OG0000008   1   0   0   0   0   0
  OG0000009   1   0   0   0   0   0
  OG0000010   1   0   0   0   0   0
  
  ```
  
  I want to use awk to print the first column if column D and E is 1 and rest is 0.
  
  ```
  OG0000004
  OG0000005
  OG0000006
  OG0000007
  
  ```
  
  I tried to do this with individual files of each column using the awk command
  
  ```
  awk 'NR==FNR{arr[$0];next} $0 in arr' file1 file2 
  
  ```
  
  but doing this I had to generate multiple files and I thought using a binary file will be a more clean way.
  
  Please Help,
  
  **Tags:** linux, awk
  
  > **Comments:**
  > **username_1**: It would be more helpful to paste the actual text instead of pictures of it.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2021-11-19. Score: 2 | Accepted answer
  
  I would do something like this:
  
  ```
  $ cat test.tsv 
  groupA  1       1       1       0       0       0
  groupB  1       1       0       0       0       0
  groupC  1       0       1       0       0       0
  groupD  1       1       1       0       0       0
  groupE  0       0       0       1       1       1
  groupF  0       0       0       1       1       0
  
  $ awk '($5==1 && $6==1 && $2+$3+$4+$7==0){print $1}'
  groupF
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you it worked  
  
  ---
  
  ### Answer by username_1 on 2021-11-19. Score: 2
  
  Straightforwardly
  
  ```sh
  awk '$2==0 && $3==0 && $4==0 && $5==1 && $6==1 && $7==0 {print $1}' bin.file
  
  ```
  
  A little spiffier
  
  ```sh
  awk '$5 && $6 && !($2 || $3 || $4 || $7) {print $1}' bin.file
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you it worked  
  
  ---
  
  