Tuesday, June 5, 2012

Bash: read csv file

Here is the script to read csv file in shell script.
#!/bin/bash
FILENAME=test.csv
OLDSEP=$IFS
IFS=,

[ ! -f $FILENAME ] && { echo "File not found : $FILENAME"; exit 99; }

while read field1 field2 field3 field4
do
    echo "$field1 : $field2 : $field3 : $field4"
done < $FILENAME

IFS=$OLDSEP

3 comments:

aonebiz99 said...

Great post, It is very helpful for me. Thanks for sharing with us. Keep posting it. Actually i was searching information about Charitable Society.

JAck Ponting said...





If you can’t remember the account that you used, support might be able to help. Get Support; Do you have an Webroot Key code? Enter your product key; Don’t have Webroot yet? If you don’t have Webroot, you can try or buy it in the webroot.com. Buy now option. If you have an webroot subscription, on your safe page

webroot.com/safe
Office.com/Setup

Fubo.tv/activate said...

Watching TV the historic common way is notable till you are caught away from domestic and pass over tonight's recreation or a new episode of your favourite show. With FuboTV, you can watch stay TV channels and stay sports activities somewhere — even away from domestic — the usage of a gadget like your smartphone or tablet. how to use fubo tv guide