split record without pattern

Hi ,

I have file with all records in one line, which needs to split it to have a fixed length.Am trying to execute the below script for the same

FILENAME="$1"
while line LINE
do
echo $LINE | awk 'BEGIN{n=1}{while(substr($0,n,10)){print substr($0,n,10);n+=10}}'
done < $FILENAME

it just displays the full line as it is...
abcdefghijklmn1234567890

instead of

abcdefghij
klmn123456
7890

Have tried with the fold -w10 as well..it seems to execute the
echo command alone..

Its quiet silly as the command executes file if executed outside the loop..
please help..

I'm not clear on what you mean here.

With fold I get:

$ echo "abcdefghijklmn1234567890" | fold -w10
abcdefghij
klmn123456
7890

EDIT: Also, what is $part?

Thanks for the quick reply...
Yes with command line it works..but when I put it in a scripts..its not working somehow..only the echo works..

FILENAME = "$1"
while line LINE
do
echo $LINE | fold -w10
done < $FILENAME

Why don't you just :

fold -w10 $FILENAME

?

or just add the fold at the end of the line in your script:

echo $LINE | awk 'BEGIN{n=1}{while(substr($0,n,10)){print substr($0,n,10);n+=10}}' | fold -w10

Thanks again..