1. 8

My first own post submission to the site. Mostly a test, since I was running a pipe earlier today and it hit me that I had written too many pipes.

Also: can we have an “awk” tag?

PS: “Killing time” might be a more appropriate phrasing?

  1. 4

    Couple of notes. “asorti” is not POSIX, so I would avoid that, however implementing your own sort is painful as well. Something I learned with AWK is you have to use the right tool for the job. So when you reach those cases when you are breaking POSIX, it might be better to use Perl, Lua or Tcl instead. Also when your “one liners” get that big, I find it helpful to just write it as a proper script:

    BEGIN {
       while ("lsof -Pn -i" | getline) {
          if (index($0, "LISTEN")) {
             split($9, a1, /:/)
             a2[a1[2]] = 1
       n1 = asorti(a2, a3, "@ind_num_asc")
       for (n2 = 1; n2 <= n1; n2++) {
          print a3[n2]
    1. 3

      +1 on the awk tag