- To: slug@xxxxxxxxxxx
- Subject: [SLUG] Re: Shell Script question
- From: Angus Lees <gusl@xxxxxxxxxxxxxxx>
- Date: Tue Aug 29 23:06:03 2000
- User-agent: Mutt/1.0.1i
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 = "''";
print;
}
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