Cat without cat on the commandline (2020)
jarv.org
jarv.org
[0] https://www.man7.org/linux/man-pages/man1/cat.1.html [1] https://www.elastic.co/guide/en/elasticsearch/reference/curr...
Yes, there may be flags you can throw on them to make them behave the way you want, but those flags need to be remembered. `cat` is certainly shorter to type and easier to remember than `less -X`
I do accept that `cat file` is not a problem, but it's interesting to discuss alternatives anyway!
Yes, there are multiple ways to get by without cat. Are they as obvious to understand? If not, what are we doing?
Shell scripting isn't meant for performance but composability. If you're fighting me over micro optimizations, I'm just going to rewrite it in a proper language and 100x its performance. But then it's lost its readability and it's no longer editable.
Balance, like most things in life.
Is it a readability problem if someone is confused about foreach loops in Java, or perhaps we should expect the person to actually learn the language they are using?
Input redirection is a fundamental shell language feature.
The useful use of cat
head filename -n `wc -l filename`
head filename -n 1000000000
or use the "inverse mode". Head and tail can print all but the first/last n lines (I just have trouble to remember without man page the syntax and which does what).
So those are more "cat equivalents": head -n-0 filename
tail -n+0 filename
PS: for your wc example you could actually do just head -n $(wc -l filename)
because `wc` will print the number of lines and the filename. (does not work with spaces)the command substitution will mangle ending newlines