I have a problem with mktemp and grep.
OUT=$(mktemp /tmp/output.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
awk -F: '{print $7}' /etc/passwd >> $OUT
grep -c $1 $OUT
In grep line, code not exits, not prints value of grep Please, help me to solve that problem.
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: