Display output bash program

Hello, i have a problem with the output from my bash program.

I made this program

#!/bin/bash

BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden

# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
    echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
    exit
fi

for i in "$BESTANDEN" 
do
    # Delete XML TAGS
    sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l 
      echo "${i}"
done

With the output:

28
1000029.xml 1000064.xml

But i need this output:

22 1000029.xml
6 1000064.xml

Can some one help me?

Remove double quotes " around variable $BESTANDEN

for i in $BESTANDEN

Thank You, now its working correct.

20
1000029.xml
8
1000064.xml

One more question, is it possible to get this output:

20 opening tags in file 1000029.xml
8 opening tags in file 1000064.xml
#!/bin/bash

BESTANDEN=( "$@" ) ## Put arguments in array
TMPFILE=xmlprog.sh.$$.$RANDOM

if [ $# -eq 0 ] ## If no arguments...
then
    echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
    exit 1
fi

for i in "${BESTANDEN[@]}"
do
    # Delete XML TAGS
    sed -e 's/></>\n</g' $i | sed 's|</.*>||g' | sed -e 's/.*\(<.*>\).*/\1/' -e '/^$/d' | wc -l
    printf "%s\n" "$i"
done

Try this,

#!/bin/bash

BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden

# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
    echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
    exit
fi

for i in $BESTANDEN 
do
    # Delete XML TAGS
echo $(sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l) " opening tags in file " $i
done

Alternatively, leave out $BESTANDEN and just use:

for i in "$@"
do

Also, use:

sed -e 's/></>\n</g' "$i" ...

Hi Guys, thanks for the replay's,

This solution is working for me right now

#!/bin/bash

BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden

# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
    echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
    exit
fi

for i in $BESTANDEN 
do
    # Verwijderen XML TAGS
    sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l > $TMPFILE-1
      echo " XML opening tags in bestand: ${i}" > $TMPFILE-2
    paste -d '' $TMPFILE-1 $TMPFILE-2 
done


rm -f $TMPFILE-1 $TMPFILE-2 

But is have a collection of 500+ xml files. So i like to have 10 xml files with the most xml tags.

Can i use something like this?

paste -d '' $TMPFILE-1 $TMPFILE-2 > $TMPFILE-3
cat $TMFFILE-3 | sort -nr | uniq | head

---------- Post updated at 11:01 AM ---------- Previous update was at 07:47 AM ----------

Hello, i have this solution

#!/bin/bash
#countxmlprog.sh : telt het aantal xml open tags uit bestanden
# aanroepen als: countxmlprog.sh bestanden
# Auteur: s2065460, frank.spin89@gmail.com

BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden

# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
    echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
    exit
fi

for i in $BESTANDEN 
do
    # Verwijderen XML TAGS
    sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l > $TMPFILE-1
      echo " XML opening tags in bestand: ${i}" > $TMPFILE-2    
    paste -d ' ' $TMPFILE-1 $TMPFILE-2 >> $TMPFILE-3
done

cat $TMPFILE-3 | sort -nr | head 

rm -f $TMPFILE-1 $TMPFILE-2 

This is my right solution.

Can i made a kind of fallback behavior when the user is not entering a file name? Now he gets a error like: "ERROR: NO File"