On Sep 30, 2014, at 12:00 PM, Brandon Allbery <[email protected]> wrote:

> On Tue, Sep 30, 2014 at 11:44 AM, Craig Treleaven <[email protected]> 
> wrote:
>> I have only rudimentary acquaintance with sed and less with awk.  I'd like 
>> to learn more and this seemed like an opportunity to do so. From some 
>> reading [1], I think sed's Hold buffer is the way to extract the port name 
>> and insert it onto the line with each of the variants.  But the tutorial 
>> only uses the hold buffer for full lines; not just, say, the first word of 
>> the line.  Is this possible?  How does one do that?
> 
> Very, very painfully. I think I could do it, with a LOT of fiddling, but 
> would very much prefer to use a more appropriate tool. awk is somewhat 
> better, but I'd reach for perl/python/ruby first.

Yup. Sed is not a great tool for this sort of thing; the functionality it 
provides is ill-suited for complex conditionals and branching. You'll regret 
writing the script as soon as you go to read/edit it in a week or month.

vq

---------->8----------

That being said, I have masochistic tendencies.

% port variants php53-mysql php54-mysql | sed -nf variants.sed
php53-mysql     mariadb N
php53-mysql     mysql4  N
php53-mysql     mysql5  N
php53-mysql     mysql51 N
php53-mysql     mysql55 N
php53-mysql     mysql56 N
php53-mysql     mysqlnd Default
php53-mysql     percona N
php54-mysql     mariadb N
php54-mysql     mysql4  N
php54-mysql     mysql5  N
php54-mysql     mysql51 N
php54-mysql     mysql55 N
php54-mysql     mysql56 N
php54-mysql     mysqlnd Default
php54-mysql     percona N
%

Attachment: variants.sed
Description: Binary data

_______________________________________________
macports-dev mailing list
[email protected]
https://lists.macosforge.org/mailman/listinfo/macports-dev

Reply via email to