Bash Read Comma Separated CSV File on Linux / Unix

Originally published at: https://www.cyberciti.biz/faq/unix-linux-bash-read-comma-separated-cvsfile/

How do I read comma separated CVS file under UNIX / Linux / BSD / MacOS bash script? My sample file is as follows
FirstName LastName,DOB,SSN,Telephone,Status
How can I parse a CSV file in Bash?

The awk program is a great tool for parsing CSV files. You can use it within a bash script.
For example, this line would print the first and second fields in a CSV file:

awk -F, '{ print $1,$2 }' filename.csv

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki