If i were you i'd do it in perl. Much easier for us mere mortals.
Something like
#!/usr/bin/perl -w
use strict;
my $i;
my @list;
open IN, "< /etc/group" or die "Can't open /etc/group\n";
while (<IN>) {
chomp;
@list = split /[:,]/;
$i = 3;
if ( defined $list[$i] ) {
open OUT, "> $list[0]" or die "Can't open $list[0]\n";
while ( defined $list[$i] ) {
print OUT $list[$i] . "\n";
$i++;
}
close OUT;
}
}
close IN;
good luck! :)
mick
On Thu, 29 Nov 2001, Les Stott wrote:
> How would I do this with something like sed?
>
> In my case I am attempting to create a new file from the /etc/group file.
> What I want to do is generate a list of all the users in a particular group
> which I can then modify and create an address book file for my webmail
> application.
>
> The group I am looking at is called "email" and I use cut and grep to paste
> the email group into a new file. Ofcourse though it goes into the new file
> as below all on one line:
>
> email: persona personb personc etc
>
> What I really want to do is turn this file into a list such as:
>
> persona
> personb
> personc
>
> This way down the track it is easier to manipulate. With you CTRL V, CTRL M
> tip in VI it works beautifully by replacing all spaces with a ^M (:g/
> /s//^M/g), thanks.
>
> So my question is if I want to do this via an automatic script what do I use
> and how? Can sed do it? or awk?
>
> Thanks in advance for all help.
>
> Regards,
>
> Les Stott
> Systems Administrator
> Rentokil Initial
> [EMAIL PROTECTED]
> (02) 9370 9348
>
>
> This email is confidential. If you are not the intended recipient, you must
> not disclose
> or use the information contained in it. If you have received this in error,
> please
> advise the sender by return email and delete the material from your
> computer.
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug