please explain the below

could u please convert the below statement to shell script
----------
logdir=/smp/dyn/logfiles/cpm/pgm/pgIm
$logdir = $logdir ."/pgIm${toDate}*";

----
could u please explain the below clearly

grep -i adding $logdir | grep -iv equation | awk '{print \$NF}' | sort -u | sed -e 's/\.\$//' > /tmp/t1

grep -i adding $logdir | grep -iv equation | awk '{print \$NF}' | sort -u | sed -e 's/\.\$//' > /tmp/t1

Looks like to me this is searching for lines of data in the $logdir that contain the word "adding" but does not contain the word "equation" then awk it searching those results for the number of fields, sort, sorts then and sed is looking to remove any \. or $ from that data, then its all getting written to a file in /tmp

I could be wrong though, I just started scripting a month ago :o