Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Sep 1999 05:33:19 -0700 (PDT)
From:      Alfred Perlstein <bright@wintelcom.net>
To:        Langa Kentane <evablunted@earthling.net>
Cc:        FreeBSD <Freebsd-questions@FreeBSD.ORG>, Linux <linux-admin@vger.rutgers.edu>
Subject:   Re: Aliases file administration
Message-ID:  <Pine.BSF.4.05.9909210427140.6368-100000@fw.wintelcom.net>
In-Reply-To: <000701bf041a$23c29a00$07a8ef9b@sunnet.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help

On Tue, 21 Sep 1999, Langa Kentane wrote:

> Hi all.
> 
> I my mail server hosts about 600 hundred users with each user allowed to
> have up to five aliaes.   Is there some front end program that I can use to
> manipulate my aliases file and be able to sort the aliases by order of the
> user the address is aliased to.  I want to be able to see how many aliases
> each user has and if they have gone over the limit.
> 
> Can you guys please suggest such an app for me.

----------------------------
#!/usr/bin/perl

require 5.004;

while ($_ = <STDIN>) {
	next if /^[ \t]*(#.*)?$/ ;	#skip blank and comment only lines
	$_ =~ s/(#.*)|(^ *)//g;		# remove comments and leading ws
	$_ =~ s/[ :,\t][ :,\t]*/ /g;
	chomp;
	$line = $_;
	@x = reverse(split(/ /,$line));
	$alias = pop(@x);
	while ($user = pop(@x)) {
		print "$user $alias\n";
	}
} 
----------------------------

run this perl script in a pipeline like so:

this_script.pl < /etc/aliases | sort

-Alfred Perlstein - [bright@rush.net|alfred@freebsd.org]
Wintelcom systems administrator and programmer
   - http://www.wintelcom.net/ [bright@wintelcom.net]




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9909210427140.6368-100000>