help me ...problem in reading a file

hi,
while reading a file line by line

# name of the script is scriptrd

while read line
do
echo $line
done

while executing
bash$ ./scriptrd
if i give the input as
*

the output is like it displays the contents of the current directory

i jus wanted it to print as *

can anybody help me in this?

#! /bin/ksh
set -f
while read line
do
echo $line
done

Look into man ksh for the -f option under set. Or look for noglob.

Hi,

Try following

#!/bin/ksh

cat <filename> | while read record
do

echo $record

done

Best Regards,
Sridhar M

Hi vino,
that was perfectly working....thank you very much.
sridhar,that code results in the same error....but thanks for responding.

Both of you have worked it out in ksh...
but it works in bash too.
is that shell specific or what? whatz the difference?

Thanks and Regards,
Kavitha

Yes it does work with bash and ksh. noglob is not shell specific. But if you go into other shells say zsh, then noglob does not exist (Atleast I couldnot find it in the man pages).

Another solution :

#! /bin/ksh
while read line
do
echo "$line"
done

Jean-Pierre.

I have a feeling it is there but it might be in the zshbuiltins man page.