PDA

View Full Version : how to count the user ID in passwd file ?


youralibaba
27th April 2010, 07:40 AM
I want to write a script to count the # of regular users (ID > 1000) and special users(ID >1 <100) in linux.

#! /bin/bash

cat /etc/passwd | cut -f3 -d':' | wc -w

plz correct the script.

giulix
27th April 2010, 09:42 AM
cat /etc/passwd |awk -F ":" '{if($3 < 1000) A++ ; else B++} END {print "<1000="A"; >1000="B}'