title: Bash - Need to check before and after date record
body: <p>My sample dataset:</p>
  
  <pre><code>Date|Name|Subject|Presence
  20200101|Aari|Maths|0
  20200102|Aari|Maths|1
  20200103|Aari|Maths|1
  20200104|Aari|Maths|0
  20200105|Aari|Maths|1
  20200101|Aari|Science|1
  20200102|Aari|Science|0
  20200103|Aari|Science|0
  20200104|Aari|Science|1
  20200105|Aari|Science|1
  20200101|Ben|Maths|0
  20200102|Ben|Maths|0
  20200103|Ben|Maths|1
  20200104|Ben|Maths|1
  20200105|Ben|Maths|1
  20200101|Ben|Science|1
  20200102|Ben|Science|0
  20200103|Ben|Science|1
  20200104|Ben|Science|1
  20200105|Ben|Science|1
  </code></pre>
  
  <p>Consider "Date-Name-Subject" as a group, within this group need to print rows which had PRESENCE=0 in that row only if PRESENCE=1 in before and after row in this sorted group. In this case,20200101 and 20200105 shall not be considered for iteration as it will not have both before and after records for checking within the group.</p>
  
  <p>My expected output for this sample data is:</p>
  
  <pre><code>20200104|Aari|Maths|0
  20200102|Ben|Science|0
  </code></pre>
  
  <p>As only these records have before and after rows with PRESENCE=1 (within the GROUP)</p>
  
  <p>. </p>