#!/bin/sh

mkdir ../program

for a in *.txt;
  do
  bzip2 -k "$a";
done

mkdir ../bzip2
mv *.bz2 ../bzip2

mkdir ../cat_bzip2
mkdir ../cat_file

for a in *;
  do
  for b in *;
    do
    if [ $a != $b ]
	then
	cat "$a" "$b" > ../cat_file/"$a"'_'"$b"
	bzip2 -k ../cat_file/"$a"'_'"$b"
	mv ../cat_file/*.bz2 ../cat_bzip2
    fi
  done
done

cd ../bzip2
(ls -l *.bz2 | awk '{print $9 " " $5}')  > ../program/filesize

cd ../cat_bzip2
(ls -l *.bz2 | awk '{print $9 " " $5}')  > ../program/filesize.cat

cd ../data
(ls -l * | awk '{print $9}')  > ../program/filename


cp ../kolmo2.class ../program
cp ../List.class ../program


cd ../program
java kolmo2 > fileout

cd ../
rm -rf cat_file
rm -rf cat_bzip2
rm -rf bzip2
