====== Parsing a CSV File with Bash ======
You can easily parse CSV files with bash. In this example script, I generate QR codes using ''qrencode'' as an example. As a source I use following very simple CSV file called ''list.csv'':
Google,https://www.google.com
Yahoo,https://www.microsoft.com
Microsoft,https://www.microsoft.com
We then parse the CSV file and execute ''qrencode'' with the parameters extracted from each line:
#!/bin/bash
while IFS=, read -r name url
do
qrencode -o "${name}.png" "${url}"
done
We can run this script like this:
bash script.sh < list.csv
Note that IFS defines the **intra field separator**. That's the character to define where a new field starts.
===== References =====
* https://www.cyberciti.biz/faq/unix-howto-read-line-by-line-from-file/
* https://mywiki.wooledge.org/BashFAQ/001
{{tag> bash csv qrencode}}