The end result is that the contents of the file ends up in the STDOUT.
For your other examples, if you use a hammer to push a screw into wood, it won’t be secure and it damages the wood. Using a board to drive a dowel through a plank might work in a pinch, but it is easier to use a hammer.
What is the bad thing that happens if you use cat for its side effect rather than to concatenate?
I do not agree with the premise that there needs to be a negative repercussion to doing something before we look at examining the behavior.
I guess I could do some serious gymnastics and reach for something like “when a text file is longer than your terminal scrollback and you cat it, you lose history that you may have been expecting to reference”.
Many of the sort of examples I’m referencing involve spawning subshells needlessly, forking/execing when it’s not actually needed, opening file descriptors that otherwise wouldn’t have been opened. We’re in an interesting bit of the tech timeline here where modern computing power makes a lot of this non-impactful performance wise, but we also do cloud computing where we literally pay for CPU cycles and IOPS.
I guess I’m just a fan of following best practices to the extent practical for your situation, and ensuring that the examples used to inform/teach others show them the proper way of doing things.
No bad things happen when I pour a Hefe into a Pilsner glass either, but now the Germans are coming for me.
Thanks for the explanation, I was wondering if it had to do with CPU cycles.
I guess I’ll continue to use cat for short files to sdout and less for longer files, if there is no actual repercussion. It’s just such a common “don’t do this” topic I was wondering if there was a good reason not to.
I think the beer in the “wrong” glass might be an apt metaphor – it might be fancier to use a specific glass, knowing the history, appreciating the golden color of the beer, (it might also affect the head on the pour? Idk) but there is also nothing wrong with drinking it out of a normal glass.
Edit: I’ve never used view, but I have a distant memory of once using more instead of less.
I guess I still don’t understand why?
The end result is that the contents of the file ends up in the STDOUT.
For your other examples, if you use a hammer to push a screw into wood, it won’t be secure and it damages the wood. Using a board to drive a dowel through a plank might work in a pinch, but it is easier to use a hammer.
What is the bad thing that happens if you use cat for its side effect rather than to concatenate?
I do not agree with the premise that there needs to be a negative repercussion to doing something before we look at examining the behavior.
I guess I could do some serious gymnastics and reach for something like “when a text file is longer than your terminal scrollback and you cat it, you lose history that you may have been expecting to reference”.
Many of the sort of examples I’m referencing involve spawning subshells needlessly, forking/execing when it’s not actually needed, opening file descriptors that otherwise wouldn’t have been opened. We’re in an interesting bit of the tech timeline here where modern computing power makes a lot of this non-impactful performance wise, but we also do cloud computing where we literally pay for CPU cycles and IOPS.
I guess I’m just a fan of following best practices to the extent practical for your situation, and ensuring that the examples used to inform/teach others show them the proper way of doing things.
No bad things happen when I pour a Hefe into a Pilsner glass either, but now the Germans are coming for me.
Thanks for the explanation, I was wondering if it had to do with CPU cycles.
I guess I’ll continue to use cat for short files to sdout and less for longer files, if there is no actual repercussion. It’s just such a common “don’t do this” topic I was wondering if there was a good reason not to.
I think the beer in the “wrong” glass might be an apt metaphor – it might be fancier to use a specific glass, knowing the history, appreciating the golden color of the beer, (it might also affect the head on the pour? Idk) but there is also nothing wrong with drinking it out of a normal glass.
Edit: I’ve never used
view
, but I have a distant memory of once usingmore
instead ofless
.deleted by creator