#!/bin/sh

mkdir program-gz/

cp -r data/ gzip/

cd gzip/

for a in *;
  do
  gzip "$a";
done

cd ../data/

mkdir ../cat_gzip
mkdir ../cat_file_gz

for a in *;
  do
  for b in *;
    do
    if [ $a != $b ]
	then
	cat "$a" "$b" > ../cat_file_gz/"$a"'_'"$b"
	cp  ../cat_file_gz/"$a"'_'"$b" ../cat_gzip/"$a"'_'"$b"
	gzip ../cat_gzip/"$a"'_'"$b"
    fi
  done
done

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

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

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


cp ../kolmo2.class ../program-gz
cp ../List.class ../program-gz


cd ../program-gz
java kolmo2 > fileout

cd ../
rm -rf cat_file_gz
rm -rf cat_gzip
rm -rf gzip
