Szerző: Daniel Tiefnig Dátum: Címzett: exim-users Tárgy: Re: [exim] bash or perl question
Nigel Metheringham wrote: > On Fri, 2006-06-23 at 16:10 +0200, Daniel Tiefnig wrote:
>> Gareth Hastings wrote:
>>> cat file | awk -F. '{print $4"."$3"."$2"."$1}'
>>>
>>> (Less typing than above!!!!)
>> UUOCAP (useless use of cat and pipe):
>>
>> awk -F. '{print $4"."$3"."$2"."$1}' file
>
> for perl aficionados...
> perl -ne 'chomp;print join(".",reverse(split(/\./)),"\n"' file
I see, you've never played golf before.
perl -ple'$_=join".",reverse split/\./' file
or
perl -F\\. -aple'$_=join".",reverse@F' file
The dot is a little show-stopper here, and its still not shorter than
the awk above.
Another approach:
perl -F\\. -alne'$,=".";print reverse@F' file
> which is neither shorter, more comprehensible or more obvious than
> the awk version... so I'm not sure why I posted it.