Long file record

riends

I have the following problem:

test.txt I have a file that has the following contents:

is a fixed-length file to the end of the number 12 has spaces, so that it is fixed length

123456789
123456789
123456789
12       

This code shows me the length of each record, but in the last record just gives me long 2 which does not help me to give me long 9 as the registration restro

while read linea
     do
       largo=${#linea}
       echo "largo es: $largo "

          if [ $largo -ne 9 ]
          then
             echo "Longitud De Registro NOK"
         fi
done <  prueba.txt

Please, try

while IFS= read linea
1 Like

thank you very much work needed to perfect what !!