#! /bin/bash

if [ $# -eq 0 ]; then
	exit
fi

#check number of lines
SIZE=`cat $1 | wc -l`
for file in "$@"; do
	if [ `cat $file | wc -l` -ne $SIZE ]; then
		echo "Number of lines in files do not coincide!"
		exit
	fi
done


bash -c "cut -f1-2 $1 > /tmp/bm.log"
CMD_LINE="paste /tmp/bm.log"
for file in "$@"; do
	bash -c "cut -f3- $file > /tmp/${file}"
	CMD_LINE="$CMD_LINE /tmp/${file}"
done

bash -c "$CMD_LINE"
