| ▲ | aozgaa 3 hours ago | |
Another solution to the pipeline example, this time making use of a subprogram for the frequency/accumulation:
If you don't allow `awk` in your "pure bash" then ofc this is not satisfactory. But it has the upside that the associative arrays are pretty explicit data structures (for the ordering and counts, respectively). | ||
| ▲ | sgarland an hour ago | parent | next [-] | |
You can skip `tr` as well - works on BSD awk and GNU awk. | ||
| ▲ | JoachimSchipper 2 hours ago | parent | prev [-] | |
Nice to see more people getting nerdsniped by the sh code. ;-) Yes, associative arrays work well. I think it should even be possible to use bash associative arrays. But at that point you're no longer doing classic sh - awk is basically halfway to Perl. (And pretty awesome.) | ||