From: Alfredo on
I've a file like this:

andrea andre(a)lol.com
antonio(a)lol.com
marco 45247(a)pop.com
kk(a)pop.com
pollo(a)lol.com
mary mary(a)lol.com


can I select only the column with email adress?

can I utilise a filter with @ ?


Alfredo
From: rthangam on
On Jun 16, 2:41 pm, Alfredo <alfreal...(a)gmail.com> wrote:
> I've a file like this:
>
> andrea an...(a)lol.com
> anto...(a)lol.com
> marco 45...(a)pop.com
> k...(a)pop.com
> po...(a)lol.com
> mary m...(a)lol.com
>
> can I select only the column with email adress?
>
> can I utilise a filter with @ ?
>
> Alfredo

If you are sure that the second column contains email id then use

awk ' { print $2 }' <filename> this will give you second column
alone.
From: Maxwell Lol on
rthangam <ramesh.thangamani(a)gmail.com> writes:

> On Jun 16, 2:41 pm, Alfredo <alfreal...(a)gmail.com> wrote:
>> I've a file like this:
>>
>> andrea an...(a)lol.com
>> anto...(a)lol.com
>> marco 45...(a)pop.com
>> k...(a)pop.com
>> po...(a)lol.com
>> mary m...(a)lol.com
>>
>> can I select only the column with email adress?
>>
>> can I utilise a filter with @ ?
>>
>> Alfredo
>
> If you are sure that the second column contains email id then use
>
> awk ' { print $2 }' <filename> this will give you second column
> alone.

Sometimes it's the first column. Sometimes the second.
This should work:

awk '$1 ~ /@/ {print $1}
$2 ~ /@/ {print $2}' <file

From: Dave B on
Alfredo wrote:

> I've a file like this:
>
> andrea andre(a)lol.com
> antonio(a)lol.com
> marco 45247(a)pop.com
> kk(a)pop.com
> pollo(a)lol.com
> mary mary(a)lol.com
>
>
> can I select only the column with email adress?

If that means "keep only email addresses", we assume that @ does not occur
in non-email words, and words are separated by spaces, then

grep -o '[^ ]*@[^ ]*' yourfile

That requires GNU grep. If you want to use awk, then

awk '{for (i=1;i<=NF;i++) if ($i ~ /@/) print $i}' yourfile

does the same thing.

With those solutions, if two email addresses occur on a single line they
will be printed as two lines.

--
echo 0|sed 's909=oO#3u)o19;s0#0ooo)].O0;s()(0bu}=(;s#}#.1m"?0^2{#;
s)")9v2@3%"9$);so%op]t(p$e#!o;sz(z^+.z;su+ur!z"au;sxzxd?_{h)cx;:b;
s/\(\(.\).\)\(\(..\)*\)\(\(.\).\)\(\(..\)*#.*\6.*\2.*\)/\5\3\1\7/;
tb'|awk '{while((i+=2)<=length($1)-18)a=a substr($1,i,1);print a}'
From: Ed Morton on


On 6/16/2008 4:41 AM, Alfredo wrote:
> I've a file like this:
>
> andrea andre(a)lol.com
> antonio(a)lol.com
> marco 45247(a)pop.com
> kk(a)pop.com
> pollo(a)lol.com
> mary mary(a)lol.com
>
>
> can I select only the column with email adress?
>
> can I utilise a filter with @ ?

No need with that input. This would do it:

sed 's/.* //' file

Ed.