[plug] function error
Russell Steicke
r.steicke at bom.gov.au
Wed Jan 11 22:05:54 WST 2006
On Wed, Jan 11, 2006 at 09:50:21PM +0800, Jon Miller wrote:
> I'm trying to get this function to work , what I need is for it to
> read the contents of a file and print it to screen 1 line at a time.
>
> The username2.txt file consists of a names 1 per line. I just need
> to to increment 1 name at a time which if I understand the while
> statement while line1 is less than 10 it should keep reading and
> increment by 1. Is the incrementing a built-in feature of bash
> while loop. If I'm right in C or C++ you had to have to use
> something like "line +1" or " ++line1"
There is no auto-incrementing loop in bourne shell (or bash) scripting
that I'm aware of.
What is it you're trying to do? Read the first 10 lines? Use a
separate counter to control the loop:
for counter in `seq 10` ; do
read LINE || break
# process $LINE
done < username2.txt
>
> #!/bin/bash
> # Reading lines in /etc/fstab.
> File=username2.txt
> function test {
> while [ "line1" < 10 ]; do
> {
> read line1
> } < $File
>
> done
>
> echo "First line in $File is:"
> echo "$line1"
> echo
> exit 0
> }
> test();
>
>
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://www.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.linux.org.au
>
--
Russell Steicke
-- Fortune says:
The only difference between a rut and a grave is their dimensions.
More information about the plug
mailing list