Live data from Hacker News

An introduction to data processing on the Linux command line

blog.robertelder.org

71–73 of 73 posts

Re: An introduction to data processing on the Linux command line

#71
post #30

Ugly UUOC (Useless Use Of Cat). Damn peoples, please i appreciate your will to share, but share good contents and stop spreading bad shell patterns....

Useless use of cat is almost always more readable and better for explanation. It shows the direction of a pipe unambiguously and splits out commands from files at a quick glance.

Re: An introduction to data processing on the Linux command line

#72
post #20

Useless use of cat detected! Rememeber, nearly all cases where you have: cat file | some_command and its args ... you can rewrite it as: and in some cases, such as this one, you can move the filename to the arglist as in: some_command and its args ... file — Randal L. Schwartz ( http://porkmail.org/era/unix/award.html#cat )

What makes it useless? It’s functionally the same but makes it easier to author pipelines , which I think is a valid use.

  cat foo | bar
is useless use of cat, since it’s equivalent to

  
which is both shorter and starts one less process. Why do you think that “cat” makes it “easier to author pipelines”?

Re: An introduction to data processing on the Linux command line

#73
post #72

Earlier quoted context omitted.

What makes it useless? It’s functionally the same but makes it easier to author pipelines , which I think is a valid use.

cat foo | bar is useless use of cat, since it’s equivalent to which is both shorter and starts one less process. Why do you think that “cat” makes it “easier to author pipelines”?

1). It doesn’t work in all shells, so you have to think about your environment before you use it.

2). I often start with `bar 3). If I just want to delete all processing and look at the input, I can’t just backspace away the processing because `< foo` is invalid.

Post reply on HN