Use the lastlog command $ lastlog | awk ' /Never logged/ { print $1}' Use the wc command $ lastlog | awk ' /Never logged/ { print $1}' | wc -l Zero. Because the line ends with two asterisks.