title: Bash Script search within a CSV File
body: <p>I hope all of you are in good health.</p>
  <p>I was working on searching within a CSV file using Bash Scripting. I have a CSV file that contain 5+ columns with the following data:</p>
  <pre><code>Col1,  Col2,     Col3,     Col4,        Col5
  1,     FName 1,  LName 1,  14:01:2019,  EXT_ABC
  2,     FName 2,  LName 2,  15:02:2020,  EXT_XYZ
  3,     FName 1,  LName 3,  16:03:2021,  PQR_LMN
  </code></pre>
  <p>I want to search within this CSV file on behalf of 2nd column that are names. I have written the following code yet.</p>
  <pre><code>read -p &quot;What is your first name?: &quot; fname
  if grep -q &quot;$fname&quot; &quot;data.csv&quot;
  then
     printf &quot;%s\n&quot; &quot;Exist.&quot;
  else
     printf &quot;%s\n&quot; &quot;Sorry, Not Exist.&quot;
  fi
  </code></pre>
  <p>This code work fine too some extent but It is searching from all the columns. If I search for <strong>LName 2</strong>, It says Exist. It should only search in 2nd column.</p>
  <p>Also, If the record exist how can I get that line from CSV. In this way If there are multiple records exist then an array should be created that contain the lines as string in which that first name exist.</p>
  <p>Can we search between 2 columns for example: I want to search the name in 2nd and 3rd column only.</p>
  <p>Thanks.</p>