News for hackers. Stuff that matters.
Re:Unix and Flow-Based Programming by throwaway999888 on Friday December 18, 2015 @06:07PM (#10761604)
> That is asinine. Why would a program be called ‘cat’ if it can’t concatenate multiple files?

Because he only thinks it's the "echo file to terminal" command.

The main use of cat was mentioned in the Programming in the UNIX environment article.

> The fact that cat will also print on the terminal is a special case. Perhaps surprisingly, in practice it turns out that the special case is the main use of the program. [...] But what about -v? That prints non-printing characters in a visible representation. Making strange characters visible is a genuinely new function, for which no existing program is suitable. [...] The answer is ‘‘No.’’ Such a modification confuses what cat ’s job is concatenating files with what it happens to do in a common special case - showing a file on the terminal.

http://harmful.cat-v.org/cat-v/unix_prog_design.pdf

Re:Unix and Flow-Based Programming by mtdewcmu on Friday December 18, 2015 @06:17PM (#10761642)
Like a lot of people, he overuses cat when it's not needed. `cat FOO | more` is approximately equivalent to `more < FOO`, except the first one spawns an extra process for no reason.
Re:Unix and Flow-Based Programming by throwaway999888 on Friday December 18, 2015 @07:04PM (#10761888)
> except the first one spawns an extra process for no reason.

I wonder how many processes I could spin up in the time it would take for me to figure out "hmm, no, invoking that command would use one more process than necessary..."

I don't give a hoot about that stuff when I'm doing stuff interactively. e.g. when using `more`.

Re:Unix and Flow-Based Programming by hawski on Saturday December 19, 2015 @12:29PM (#10764168)
In my opinion it's better to replace `cat FOO | more` with `< FOO more`, because cat is used because people first think that they want to take contents of some file and pass it through some filter.
Re:Unix and Flow-Based Programming by mtdewcmu on Saturday December 19, 2015 @03:10PM (#10764664)
I didn't know you could put the redirection first. You learn something new every day. Maybe that form would make it more mnemonic for some people, because it more resembles a pipeline.
Re:Unix and Flow-Based Programming by throwaway999888 on Friday December 18, 2015 @08:16PM (#10762139)
BTW, the authors effectively embraced having the functionality of using `cat` instead of < .

> The use of cat to feed a single input file to a program has to some degree superseded the shell’s < operator, which illustrates that general-purpose constructs - like cat and pipes - are often more natural than convenient special-purpose ones.

Re:Unix and Flow-Based Programming by mtdewcmu on Friday December 18, 2015 @11:04PM (#10762573)
If you're going to write shell scripts or do anything sophisticated with the shell, it's worth understanding the difference. And there is a fundamental difference. With |, standard input is hooked up to a pipe. With <, standard input is hooked up directly to the file. Sometimes it does matter.
Re:Unix and Flow-Based Programming by isolate on Friday December 18, 2015 @11:13PM (#10762592)
The purpose cat serves is that it lets you forget about < until you really need it.
Re:Unix and Flow-Based Programming by throwaway999888 on Saturday December 19, 2015 @05:47AM (#10763227)
The comparison was between cat + pipe and < ...