#!/bin/bash
# fusion du résultat des fichiers _occ dans le fichier total
# produit total et total-1 qui n'inclut pas les mots non répétés.

date > total
date > total-1
echo "INDEX" > index

wc -l * | sort -nr | erg-suppr_num  | grep   "\_occ" | sed -e "s/total//g"  >  "total liste"

cat "total liste" | while read i
do
	cat "$i" | grep -w "1" > "total test"
	test="$(wc -l "total test" | cut -f1 -d " ")"
	long="$(wc -l "$i" | cut -f1 -d " ")"
	if [ "$test " != "$long" ]
	then
		echo -e "\n$i" | sed -e "s/-suppr_occ//g"  >>  total
		cat "$i" | sort -nr >> total
	fi
	echo -e "\n$i" | sed -e "s/-suppr_occ//g"  >>  total-1
	cat "$i"  | sort -nr | grep -wv 1 >> total-1
	echo "$i"| sed -e "s/-suppr_occ//g" >> index
done
# LOG head total
