Reading one line at a time

Hi All,

I'm trying to write an script where I'll be processing all the lines of an input file but one line at a time and produce a written output for each processed line.

Where I'm having problems is preparing the loop where I check a the first line of the input file cut some bytes out of the line and echo them in the screen.

What I had in mind is something like this

#!/usr/sh

FILE=$1
while (we haven't reach the end of the file)
do
VAR1=$(cut -b x-y $curent Line
echo "The value is : $VAR1"
done

Any help is well appreciatted.

the usual paradim is:

#!/bin/ksh

while read line
do
   echo 'do my magic here with line: [${line}]'
done < myFile

if your 'line' consistently in the same format you might not need to do any 'cut-ting'.
what does your 'line' look like?

each line is a string of numbers (no spaces) 120 characters long.

The intention is to present some of the charaters (according to its positions) of each line in the std output.

I'll give it a try at your code and see what the output is.

Thanks

I forgot to mention that I would like to use the bourne or bash shells for this script

The solution is the same for bourne, bash and korn shell :

#!/bin/sh

while read line
do
   the_number=$(echo "$line" | cut -b x-y)
   echo 'The number is: [${the_number}]'
done < myFile

If you need only the number from lines of your file, extract the number from the file and read the resilt line by line :

#!/bin/sh

cut  -b x-y myFile |
while read the_number
do
   echo 'The number is: [${the_number}]'
done

Jean-Pierre.