From my experience, it will never be so efficient that someone smarter than me doesn't publicly shame me for winning the "useless use of cat" award on a forum where I ask for help. 28 years later and I'm still sore I asked for help as a 15 year old that one time. Very effective way to teach a new user.
Another reason I still use "cat" is that I don't want the remaining commands to modify the input file, but I don't want to spend the time to inspect the command line to make sure that is the case. For example I'm pretty sure "grep" won't change the input file but "sed" may depending on the "-i" flag. Using "cat" conveniently bypasses all that thinking because the program only gets stdin from a pipe.
How efficient can cat(1) be?
41–50 of 51 posts
Re: How efficient can cat(1) be?
#42Re: How efficient can cat(1) be?
#43Earlier quoted context omitted.
Another reason I still use "cat" is that I don't want the remaining commands to modify the input file, but I don't want to spend the time to inspect the command line to make sure that is the case. For example I'm pretty sure "grep" won't change the input file but "sed" may depending on the "-i" flag. Using "cat" conveniently bypasses all that thinking because the program only gets stdin from a pipe.
You can replace `cat file | cmd` with just `cmd Even when trying to say something like `echo $(cat foo)`, in Bash you can write `echo $(<foo)`. Though other shells may still require `cat` in this scenario.
Re: How efficient can cat(1) be?
#44Earlier quoted context omitted.
that’s a lesson that’s no longer applicable on modern machines I think? —- it often makes sense to start a sequence of piped commands with a cat invocation. One reason is that then the order of sources and sinks in the command syntax matches reality.
I always pipe from cat, as a matter of habit. Reason being: I've probably just catted the file at least once, and it's even likely I catted it right before piping it. So I can extend that command from the history, and if I keep piping (likely) I don't have the weird syntactic stutter at the beginning where `blah Also, you can't mistype `cat file.txt | blah` and overwrite file.txt accidentally with the output of blah.…
Re: How efficient can cat(1) be?
#45Earlier quoted context omitted.
I always pipe from cat, as a matter of habit. Reason being: I've probably just catted the file at least once, and it's even likely I catted it right before piping it. So I can extend that command from the history, and if I keep piping (likely) I don't have the weird syntactic stutter at the beginning where `blah Also, you can't mistype `cat file.txt | blah` and overwrite file.txt accidentally with the output of blah.…
‘<file.txt blah’ works just fine.
Re: How efficient can cat(1) be?
#46Earlier quoted context omitted.
I always pipe from cat, as a matter of habit. Reason being: I've probably just catted the file at least once, and it's even likely I catted it right before piping it. So I can extend that command from the history, and if I keep piping (likely) I don't have the weird syntactic stutter at the beginning where `blah Also, you can't mistype `cat file.txt | blah` and overwrite file.txt accidentally with the output of blah.…
‘<file.txt blah’ works just fine.
head filename | ...
Once its working I find it easy to just type C-aM-dcat (i.e. beginning-of-line kill-word cat).Re: How efficient can cat(1) be?
#47Earlier quoted context omitted.
You can replace `cat file | cmd` with just `cmd Even when trying to say something like `echo $(cat foo)`, in Bash you can write `echo $(<foo)`. Though other shells may still require `cat` in this scenario.
Or <file cmd, to preserve the order.
Re: How efficient can cat(1) be?
#48Earlier quoted context omitted.
I always pipe from cat, as a matter of habit. Reason being: I've probably just catted the file at least once, and it's even likely I catted it right before piping it. So I can extend that command from the history, and if I keep piping (likely) I don't have the weird syntactic stutter at the beginning where `blah Also, you can't mistype `cat file.txt | blah` and overwrite file.txt accidentally with the output of blah.…
‘<file.txt blah’ works just fine.
100% aesthetic, I shouldn't be able to point a file at my prompt and have it end up streamed into the next word. Just awful, 0/10, do not want.
Re: How efficient can cat(1) be?
#49Earlier quoted context omitted.
‘<file.txt blah’ works just fine.
Thanks for the reminder (sincerely) but to me this is worse, I would use a shell which doesn't offer this particular form of irregular grammar, I hate it. 100% aesthetic, I shouldn't be able to point a file at my prompt and have it end up streamed into the next word. Just awful, 0/10, do not want.
Re: How efficient can cat(1) be?
#50Earlier quoted context omitted.
Or <file cmd, to preserve the order.
That works in Bash, it doesn't work in all other shells though (it doesn't work in Fish at least, I haven't checked others).