[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: bash script



Try this:

while read -r line
do
  echo $line
done < abc.xyz

Saravanan Subbiah wrote:

> I have a small problem which is bugging me.
>
> Suppose I have a file abc.xyz, which has the following content.
>
> line1col1 line1col2 line1col3
> line2col1 line2col2 line2col3
>
> Now, the following script
>
> for line in `cat abc.xyz`
> do
>         echo $line
> done
>
> prints the file each element wise. i.e. The output is
>
> line1col1
> line1col2
> line1col3
> line2col1
> line2col2
> line2col3
>
> But I want to print line by line. ie. I want $line to contain an entire
> line, instead of each
> element.
>
> How do I do it ?
>
> thanks,
> -Saravanan
>
>
>
>
>
>
> ---------------------------------------------
> The mailing list archives are available at
> http://lists.linux-india.org/cgi-bin/wilma/linux-india-programmers

--
Many of the life's failures are people who didn't realize how close they
were to success
when they gave up
      --Thomus Edison