Re: Compare two files and remove if not found ?
- From: pk <pk@xxxxx>
- Date: Tue, 04 Mar 2008 16:55:37 +0100
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 :-)
.
- References:
- Compare two files and remove if not found ?
- From: donetnoc
- Re: Compare two files and remove if not found ?
- From: Ed Morton
- Re: Compare two files and remove if not found ?
- From: donetnoc
- Compare two files and remove if not found ?
- Prev by Date: Re: something in awk that prints from $2 to NF
- Next by Date: Re: Compare two files and remove if not found ?
- Previous by thread: Re: Compare two files and remove if not found ?
- Next by thread: Re: Compare two files and remove if not found ?
- Index(es):
Relevant Pages
|
|