jueves, 7 de febrero de 2019

TIL: paste -sd+

Following https://hacker-tools.github.io/ lectures, I found a neat trick I didn't know in the data wrangling chapter:

seq 100 | paste -sd+ | bc -l     # 5050


That's pretty nice.  I already had this usecase solved by an "addup" perl script that I stole years ago from Mark Jason Dominus' utils repo.

As a bonus, it reminds me the very similar trick to generate a regex that matches either of many words. That's part of my git pre-commit hook


Not exactly the same, but it also belongs to "Higher Order Shell"

No hay comentarios: