* This one time, at band camp, Les Stott said:
> 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?
> 

You can do it in awk, sed and perl.  However its early and my brain
can't remember awk and sed syntax this early, so here it is in perl...

echo "email: test test test test" | perl -e 'foreach (split(/\s+/,<STDIN>)){next if 
m/email/; print "$_\n"}'

the 'foreach (split(/\s+/,<STDIN>))' splits STDIN into segments based on
whitespace (\s+ means at least one but no max whitespace).

'next if m/^email/'  skips any line starting with the string email

'print "$_\n"' print the buffer ($_) and a newline (\n)

The newline char is the key, that will be the same in sed,perl,awk,c, etc etc

HTH

Greeno
-- 
Greeno <[EMAIL PROTECTED]>
GnuPG Key :  1024D/B5657C8B 
Key fingerprint = 9ED8 59CC C161 B857 462E  51E6 7DFB 465B B565 7C8B

Imagine working in a secure environment and finding the string 
_NSAKEY in the OS binaries without a good explanation
    -Alan Cox 04/05/2001

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to