I have a problem at line 14 and 16 where there are the nested if statments. It returns me command not found error, but I tested that part of code and it's ok used elsewhere.
#passing the argument page page.html
cat $1 | grep -o "wp-cli.org/commands/cache/\w*/\"" > temp.txt
#creating all pdf files
for i in $(cat temp.txt)
do 
source=$(echo $i | grep -o -P "wp-cli.org/commands/cache/\w+")
dest=$(echo $i | grep -o -P "\w+/\"" | grep -o -P "\w+")
#echo $source $dest
wkhtmltopdf $source $dest".pdf"
pdfCount=$(ls *pdf | wc -l)
echo $pdfCount
if [ ! -f sample.pdf ]
then
 if [$pdfCount -eq 1] 
 then
    firstPdf=$dest".pdf" 
 fi
 if [$pdfCount -eq 2]
 then
    pdfunite $firstPdf $dest".pdf" sample.pdf
 fi
else
    pdfunite $dest".pdf" oldsample.pdf sample.pdf
    mv sample.pdf oldsample.pdf
fi
done
Anyone has an idea about? Thanks...
"$firstPdf"will save you from some headaches in the future if you start getting filenames likeContract 2017. Good luck.for ... cat, etc) - so... just wondering. :)