The CSV file, or list of comma-separated values, will come from the file named tools that we have in a current directory. This is a catalog of products that we sell. The file content is shown in the following output:
drill,99,5 hammer,10,50 brush,5,100 lamp,25,30 screwdriver,5,23 table-saw,1099,3
This is just a simple demonstration, so we don't expect too much data, but each item in the catalog consists of the following:
- Name
- Price
- Units in stock
We can see that we have a drill that costs $99 and we have five units in stock. If we list the file with cat, it is not very friendly; however, we can write a script to display the data in a more appealing way. We can create a new script called $HOME/bin/parsecsv.sh:
#!/bin/bash OLDIFS="$IFS" ...