Re: Compare two files and remove if not found ?



donetnoc@xxxxxxxxx wrote:

The passwd file has entrys like this
user1010:x:23524:200::/local/home/user1010:/bin/bash

The aliases file has entrys like this

user_emailadress:user1010

The username can occur one or many times.

I need to clean the aliases file from entrys that does not exist in
the passwd file so the output should be a new aliases file with
usernames that only
exist in the passwd file.

Here was a rough attempt with awk:

awk -F ':' 'FILENAME == "/etc/passwd" {n[$1] = $1}
(FILENAME == "/etc/aliases") && (n[$2]!="") {print}' \
/etc/passwd /etc/aliases

But Ed already posted a more concise and elegant solution :-)

.



Relevant Pages

  • Re: LDAP_ROUTE feature with access db
    ... when their username on our email server can have only ... this in the access file: ... virtusertable to specify custom error message ...
    (comp.mail.sendmail)
  • Re: sendmail newbie question
    ... > If I understand correctly you're saying that by and large, modern Unix ... trying to make your username mixed case will give you ... virtusertable to translate e-mail address -> username on the incoming ... See aliasesfor the syntax of the aliases file. ...
    (freebsd-questions)
  • Re: Compare two files and remove if not found ?
    ... I have an aliases file that have not been maintained according to the ... aliases dows not exist in the passwd file. ... not found in password file it does not mean that it should be dropped ... That means that after the left portion of each entry is ...
    (comp.unix.shell)