#!/bin/sh

mkdir ../program

for file in *;
  do 
  bzip2 -k "$file";
done

mkdir ../data-bzip2
mv *.bz2 ../data-bzip2

mkdir ../cat-bzip2
mkdir ../cat-file

for file1 in *;
  do
  for file2 in *;
    do
    if [ $file1 != $file2 ]
	then
	cat "$file1" "$file2" >  ../cat-file/"$file1"'_'"$file2"
	bzip2 -k ../cat-file/"$file1"'_'"$file2"
	mv ../cat-file/*.bz2 ../cat-bzip2
    fi
  done
done

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

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

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

cd ../
rm -rf cat-file
rm -rf cat-bzip2 
rm -rf data-bzip2
