title: How to write if-else statement if the user input is matched or unmatched with the record in text file in bash?
body: <p>I currently have a text file called <code>student.txt</code> and there are some records in the text file.
  The format of the records are <code>StudentID|Name|ContactNumber|EmailAddress</code> and the records are as follows:</p>
  <pre><code>21PMR07222|Steven|011-1234567|steven@yahoo.com
  21PMR07123|John|012-3456789|john@yahoo.com
  21PMR07221|Amy|017-4567890|amy@gmail.com
  </code></pre>
  <p>How to put the following code into <code>if-else</code> statement where if the student ID entered by user is matched with the student ID in the text file, the details of the student will be displayed, else error message <code>&quot;The student ID does not exist. Please enter again.&quot;</code> will be displayed.</p>
  <pre><code>awk -F'|' -v id=&quot;$studentID&quot; '$1 == id { printf &quot;Name: %s\nContact Number: %s\nEmail Address: %s\n&quot;, $2, $3, $4 }' &lt; student.txt
  </code></pre>