#!/bin/bash

#datafile=$1 

cat /dev/null > pl2files_c12_34eq.dat 	# clear the output file

for datafile in ep*.pl2 		# loop over all ep*.pl2 files
do
    if [ -s $datafile ]; 		# test if datafile is not zero bytes
    then
	echo Working on $datafile
	date=${datafile:3:5}		# extract yydoy from filename
	awk '{if( $2==12 && $3==$4) counter=counter+1}; END{print '$date' " " counter}' < $datafile >> pl2files_c12_34eq.dat
    fi        
done