Adding characters at the top of all files in directory

Hi Unix experts;

I have 30000 files in a directory and am willing to do the following changes on each of them. The input files look like the following:

1 ,  2
3  ,  4
5  ,  6
7  ,  8
9  ,  10

the output will have # in top 10 lines, insert space instead of comma. This looks like:

#
#
#
#
#
#
#
#
#
#
1     2
3     4
5     6
7     8
9    10

I have come up with the following. But don't know how I can put # in the first 10 lines:

for file in $(ls -l *)
do
echo $file | sed 's/,/ /g' >output
done

Regards

What about:


ls | while read FILE; do
cat << ! > $FILE.new
#
#
#
#
#
#
#
#
#
#
$(sed "s/,/ /" $FILE)
!
cp -f $FILE.new $FILE && rm $FILE.new
done

Or to avoid a UUOC award...

ls | while read FILE; do
echo "#
#
#
#
#
#
#
#
#
#
$(sed "s/,/ /" $FILE)
" > $FILE.new
cp -f $FILE.new $FILE && rm $FILE.new
done

That merits a UUOL award. (And it will fail if there are any spaces in any of the filenames.)

for file in *
do
  {
    printf "%s\n" '#' '#' '#' '#' '#' '#' '#' '#' '#' '#'
    sed 's/,/ /g' "$file"
  } > output && mv output "$file"
done

Thanks for different options! How can i add one space at the beginning of each line while doing the previous task, i.e.

#
#
#
 1    2
 3    4
 5    6
 6    7
 8    9

The only change is the space befor each data line only

---------- Post updated at 08:15 PM ---------- Previous update was at 08:01 PM ----------

whoops!! I did it by adding another sed!

Thank you very much anyways

You don't need another sed; just another command to the same sed:

for file in *
do
  {
    printf "%s\n" '#' '#' '#' '#' '#' '#' '#' '#' '#' '#'
    sed -e 's/,/ /g' -e 's/^/ /' "$file"
  } > output && mv output "$file"
done

'Nuff sed!