tl;dr version:
How do I transform a listing like this:

$ port variants php53-mysql php54-mysql |grep -v conflicts |grep -e mariadb -e mysql -e percona | cut -d : -f 1
php53-mysql has the variants
   mariadb
   mysql4
   mysql5
   mysql51
   mysql55
   mysql56
[+]mysqlnd
   percona
php54-mysql has the variants
   mariadb
   mysql4
   mysql5
   mysql51
   mysql55
   mysql56
[+]mysqlnd
   percona

into:

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


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?

[1] http://www.grymoire.com/Unix/Sed.html#uh-52

Or maybe I'm barking up the wrong tree? Is there another tool/technique that is better suited?

Thanks in advance,

Craig
_______________________________________________
macports-dev mailing list
macports-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-dev

Reply via email to