News for hackers. Stuff that matters.
Re:Problem solving with Unix commands by Apes on Thursday February 14, 2019 @11:50AM (#19163309)
To be fair, it's possible to make this block simpler and more readable than what you have there. The problem with a lot of bash scripts I've seen is that they just duck-tape layer after layer of complexity on top of each other, instead of breaking things into smaller, composable pieces.

Here's a quick refactor for the block that I would say is simpler and easier to maintain.

  function xform() {
    local dir="$1"
  
    ls -1 "$dir"           |
    grep '\d\d\d\d_A.csv'  |
    cut -c 1-4             |
    python3 parse.py       |
    uniq
  }
  
  comm -1 -3 <(xform dataset-directory) <(seq 500)

There are no comments on this comment yet.