title: How to grep patterns from stdin
body: <p>I made a Bash script some time ago to find duplicate files <code>/home/usr/xxx/bin/finddup.sh</code></p>
  
  <pre><code>#!/bin/bash
  DIR=${1:-`pwd`}
  FILENAME=`basename $0`
  DATETIME=`date +%Y%m%d%H%M%S`
  TMPFILE=`mktemp /tmp/${FILENAME}.${DATETIME}` || exit 1
  find -P $DIR -type f -exec cksum {} \; | sort | tee $TMPFILE | cut -f 1-2 -d ' ' | uniq -d | grep -if - $TMPFILE | sort -nr -t' ' -k2,2 | cut -f 3- -d ' ' | while read line; do ls -lhta "$line"; done
  </code></pre>
  
  <p>But today when I tried to use it again, it didn't work.  The problem seems to be from the <code>grep -if - $TMPFILE</code> step where it failed to find lines of duplicated files from <code>$TMPFILE</code> with patterns provided from stdin.  I cannot figure out the correct usages of <code>-</code> here.  Anyone can enlighten me?</p>