cat /etc/passwd and grep -v on /etc/shells

Hi All,

I'd like to do this

cat /etc/passwd

and grep -v on the /etc/shells list

I'd like to find all shell that doesn't exist on the /etc/passwd.

Is there an easy way without doing a egrep -v "/bin/sh|/bin/bash................"?

How do I use a file /etc/shells as my list for search entries?

Thanks and more power.

#!/bin/sh

for shell in $(</etc/shells)
do
  count=`grep -c $shell /etc/passwd`
  if [ $count -eq 0 ]
  then
    echo $shell not used in /etc/passwd
  fi
done

To give the file as input it is -f FILENAME in grep.

But am not sure whether it fits for your requirement or not!!

grep -v -f /etc/shells /etc/passwd

Try this:

awk 'NR==FNR{a[$NF];next} !($0 in a)'  FS=":" /etc/passwd FS="/" /etc/shells

Oohhh, I always ignore reading all these param......

This is what I want.

grep -v -f /etc/shells /etc/passwd

Thanks to ALL!