Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Macrokernel or microkernel or a grain of salt, whatever kernel you use does not matter when it comes to seeing the advantages of 'the *nix philosophy'. As to the 'useless uses of cat' these often make the pipe easier to grasp because the first step is always the same:

   cat something|filter step 1|filter step 2|filter step 3
instead of

   filter step 1 something|filter step 2|filter step 3
especially when confronted with filters which need their input to be fed in different ways

   filter step 1 < something
   filter step 1 -i something
   filter something step 1
   cat something|filter step 1
It may be less 'pure' to use cat as the first step in a pipe but who cares?


You can keep the order of things even if you want to avoid using cat:

   < something filter step 1|filter step 2|filter step 3
(just pointing this out in the hope it can be of interest to someone reading the thread, I don't personally care that much about UUOC - "useless" is quite subjective, one can still reasonably find the cat version more readable).


Oh I don't care: I do it all the time when I compose cli commands. But is it doing one thing, and doing it well, to use `cat – concatenate and print files` to open a file?

I think it's a good example of when it's worth straying from the philosophy.


> But is it doing one thing, and doing it well, to use `cat – concatenate and print files` to open a file?

Yes, it 'prints' the file to stdout which is consumed by the pipe and turned into the input for the next command in the pipeline. It doesn't matter whether you're only 'printing' a single file or a bunch of them.


And it numbers empty lines (-b) and non-empty lines (-n) and the end of lines (-E) and elides empty lines (-s) and search-and-replaces tabs (-T) and nonprinting characters (-v)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: