Unix / Linux Shell: Parse Text CVS File Separator By Field

Posted on in Categories , , last updated March 4, 2014

I work for a small ISP (Internet Service Provider) and we are using Linux and Unix-like operating system with bash shell. I want to write a shell script to parse the csv file line by line. Then line must be parse again field by field. The sample input file is as follows:


I need to extract each of these example.com,username,groupname,homedir,md5password,permission,secondarygroup fields and passed to the different system utilities. How do I write a shell script to automate this task and use the bash shell to parse a text file?

Bash Shell Read a Line Field By Field

Posted on in Categories last updated March 15, 2010

How do I read a file field-by-field under UNIX / Linux / BSD Bash shell? My sample input data file is as follows:



For each line I need to construct and execute a shell command as follows:

/path/to/deviceMaker --context=$1 -m $permissions $device2 $deviceType $major $minor