Tugger the SLUGger!SLUG Mailing List Archives

[SLUG] Re: Shell Script question

On Tue, Aug 29, 2000 at 03:56:29PM +1100, Erich Schulz wrote:
> If this really is a simple subbstitution, try using gawk, it will automatically
> handle the line input, and you can set the filed seperator to be the comma
> (FS=,) which will parse all teh fields for you.

just in case you were wondering:

#! /usr/bin/awk -f

BEGIN { FS = OFS = "," }

  for (i = 0; i < NF; i++)
    if (!$i) $i = "''";

awk is a very nice simple language and perfect for these sorts of tasks.

(you can make this into a much shorter one-liner, if you wanted to use
it in a shell script)

 - Gus