ksh script --reading file line by line?

ksh script --reading file line by line?

Post by Doug Lens » Fri, 30 Jul 1999 04:00:00



Ok,  I give up. Nothing seems to work in script.

Normally read a file with a whiile loop.  But in
this script IFS is reset at the beginning to read
a source file correctly. {IFS='|'}

Now I want a function to read a debugging file
line by line. The debugging file  is  simply two  columns
with a comma dividing columns.

Problem  is  read command will only  read the first
line and never proceeds to other lines.

While loop is in a function.
I have tried resetting IFS  {IFS=','} and used typeset,
but still  only reads one line. Closest I can get is to
define IFS as -- IFS=",$'\n'". Then I can read more
lines in file but:
  1. never complete reading entire file
  2. char 'n' is now used as a field delimiter instead of newline.

Questions:
1. what's going on?
2. How fix?

many thanks

doug

--

 
 
 

ksh script --reading file line by line?

Post by Doug Lens » Fri, 30 Jul 1999 04:00:00


Answers:
1. problem was in grep command not function
2. to set IFS =newline use  IFS='\012'


.Ok,  I give up. Nothing seems to work in script.
.
.Normally read a file with a whiile loop.  But in
.this script IFS is reset at the beginning to read
.a source file correctly. {IFS='|'}
.
.Now I want a function to read a debugging file
.line by line. The debugging file  is  simply two  columns
.with a comma dividing columns.
.
.Problem  is  read command will only  read the first
.line and never proceeds to other lines.
.
.While loop is in a function.
.I have tried resetting IFS  {IFS=','} and used typeset,
.but still  only reads one line. Closest I can get is to
.define IFS as -- IFS=",$'\n'". Then I can read more
.lines in file but:
.  1. never complete reading entire file
.  2. char 'n' is now used as a field delimiter instead of newline.
.
.
.Questions:
.1. what's going on?
.2. How fix?
.
.many thanks
.
.doug
.
.
.
.
.
.
.--
.

-