Subject: Re: shell script question
To: Lubos Vrbka <shnek@chemi.muni.cz>
From: David Laight <david@l8s.co.uk>
List: netbsd-help
Date: 02/11/2003 12:21:34
On Tue, Feb 11, 2003 at 11:54:42AM +0100, Lubos Vrbka wrote:
> i'm testing the script now... the advisory was to do
> 
> while read i j < file1
> do
>    mv file2 file2.tmp
>    sed -e "s/\ $i\$/\ $j/" < file2.tmp > file2
> done
> 
> problem is that the "while command" reads all the time only the first 
> line of the file :o( what i'm doing bad? (script shell is /bin/ksh)

You need to redirect the input of the while loop, not the read
command.  ie:

while read xxx
do
	...
done < file

Alternately change where the shell reads its input from with:

exec < file
while read xxx; do ...; done

This has the advantage of not running the loop in a sub-shell so
assignments made to shell variables inside the loop are visible
after the loop terminates.

	David

-- 
David Laight: david@l8s.co.uk