I currently have a text file called student.txt
and there are some records in the text file. The format of the records are StudentID|Name|ContactNumber|EmailAddress
and the records are as follows:
21PMR07222|Steven|011-1234567|steven@yahoo.com
21PMR07123|John|012-3456789|john@yahoo.com
21PMR07221|Amy|017-4567890|amy@gmail.com
User is allowed to search the students details using studentID
. I have the following codes to display the student details if the studentID
was found, else it displays error message.
output=$(awk -F'|' -v id="${studentID^^}" '$1 == id { found=1; printf "Name: \033[1m%s\033[0m Contact Number: \033[1m%s\033[0m Email Address: \033[1m%s\033[0m", $2, $3, $4 } END { if (found==0) { printf "The student ID entered does not exist! Please enter again." }}' student.txt)
And currently the output is shown as below (the details are displayed in bold):
Name: **Steven** Contact Number: **011-1234567** Email Address: **steven@yahoo.com**
May I know how can I let the output shown as below? (I do not want the details to display in one whole line, I want the details to be displayed in separate lines and the details are displayed in bold)
Name: **Steven**
Contact Number: **011-1234567**
Email Address: **steven@yahoo.com**