BlackPearl above probably is correct - $1
likely is empty during your program execution. As a result, the grep command looks like this: grep -c $OUT
which tells grep to look for $OUT
in the stdin. stdin is the keyboard (I suspect) so grep will wait forever (well, until you press Ctrl-D or Ctrl-C).
To solve your problem, specify a parameter when you execute your script.
You can also avoid the problem entirely by counting all of the unique values in your passwd file like this:
OUT=$(mktemp /tmp/output.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
awk -F: '{print $7}' /etc/passwd >> "$OUT"
sort "$OUT" | uniq -c # count each unique value in passwd file column 7