write file

Hi all,
I want to append some 20 statements into a file. I'm doing now in ksh script as,
echo �Statement1" >> filename
..........................................
.........................................
echo "statement20" >> filename

I guess that above code will open, write & close file for 20 times.

Pls suggest me to do it in single open, write & close? Correct me if I'm wrong here.

Regards,
Poova.

use sed with a\ option

IMHO the best way in this scenario is to add the commands with an editor (vi) in the file.

Regards

with (very) little modification

{
    echo �Statement1"
    ..........................................
    .........................................
    echo "statement20"
} >>  filename

Purists will use inward redirect rather than cat, but this is the usual method to create a file line-by-line in shell.

#!/bin/ksh
# Append lines to existing file called "filename"
cat <<EOF >>filename
statement1
statement2
statement3
statement4
statement5
EOF

Thanks all. Nice experience.