#!/bin/bash
mkdir temp
cd temp
rm *.txt
rm *.bz2
rm *.pgn
wget https://database.lichess.org/standard/list.txt
echo "" >> list.txt
tac list.txt > list2.txt
mv list2.txt list.txt
touch enpassant3.txt
while IFS= read -r line; do
	echo $line
	wget $line
	lbzip2 -d *.bz2
	< *.pgn parallel --pipe -j16 --block 50M --quote grep -B 18 -E  ' ([a-z])4[?!]* ({[^}]*} [0-9]+... ){0,1}[a-z]x\1(3)#| ([a-z])5[?!]* ({[^}]*} ){0,1}[0-9]+. [a-z]x\4(6)#' >> enpassant3.txt
	rm *.bz2
	rm *.pgn
done < "./list.txt"
