[clug] Please help
Stephen Jenkin
sjenkin at canb.auug.org.au
Tue Jun 1 08:50:26 GMT 2004
On Tue, 1 Jun 2004, Martin Pool wrote:
> On 1 Jun 2004, "Crosskey, Jason (DPS)" <Jason.Crosskey at aph.gov.au> wrote:
> > I can't get this script to work in bash, see bleow, but it works in ksh.
> > Variables get lost after the while loop is done in bash which causes the
> > problem, but I don't know how to fix it.
> >
> > hostfile=/etc/hosts
> >
> > echo "This program will find a host name in $hostfile"
> > echo "Enter an IP address:" ;read findIP
> >
> > while test "$findIP" != 999
> > do
> > cat $hostfile | while read line
>
> maybe
>
> while read line < $hostfile
I tried this first off. 'bash' barfs on it, v. strange.
An alternative works:
exec 3< $hostfile
while read -u3 line
>
>
> --
> Martin
>
Steve Jenkin, Unix Sys Admin
0412 786 915 (+61 412 786 915)
PO Box 48, Kippax ACT 2615, AUSTRALIA
More information about the linux
mailing list