People who get up in arms about "useless" uses of cat need to chill out. I read my pipelines left to right. Using a ' after the command means I have to swap my reading direction back and forth, and why bother with that? I have better things to do with my brain energy.
The useful use of cat
31–40 of 113 posts
Re: The useful use of cat
#32Using `cat file.txt | ...` has always felt more natural to me, so I still use it. If I need to build a long command I've been using the excellent `up` tool to do it, e.g. `cat file.txt | up` https://github.com/akavel/up
Re: The useful use of cat
#33Re: The useful use of cat
#34cat concatenates files together. I often use it for that. Who cares if "files" is just one file? Using cat regardless keeps things uniform. I like it. People who get funny about it are just trying to be clever. Yes I know there are other ways to do it. But you understood what cat did, otherwise you wouldn't have commented on it.
Re: The useful use of cat
#35if you prefer to use cat just to read your pipeline from left to right, you can just start your command with file redirection. It doesn't have to be at the end of the command. this works in bash too, but if you're using zsh, there're a couple of nice shortcuts on it's own works as more file and > file ... ... ^D allows you to put something into the file quickly without firing up the editor. Though > file will give yo…
It would give me pause. If I saw cat file | grep ...
I would understand it instantly, as would any other Unix user. Therefore the latter is better code.Re: The useful use of cat
#36 cat | sudo tee somefile > /dev/null
is still my favorite way to paste text into an ssh session and save it to a protected file.Re: The useful use of cat
#37if you prefer to use cat just to read your pipeline from left to right, you can just start your command with file redirection. It doesn't have to be at the end of the command. this works in bash too, but if you're using zsh, there're a couple of nice shortcuts on it's own works as more file and > file ... ... ^D allows you to put something into the file quickly without firing up the editor. Though > file will give yo…
Re: The useful use of cat
#38Re: The useful use of cat
#39if you prefer to use cat just to read your pipeline from left to right, you can just start your command with file redirection. It doesn't have to be at the end of the command. this works in bash too, but if you're using zsh, there're a couple of nice shortcuts on it's own works as more file and > file ... ... ^D allows you to put something into the file quickly without firing up the editor. Though > file will give yo…
If I saw It would give me pause. If I saw cat file | grep ... I would understand it instantly, as would any other Unix user. Therefore the latter is better code.
Re: The useful use of cat
#40`cat x | head` attaches `cat x`'s stdout to `head`'s stdin, `Though I will note that, in a way, bash supports this, as it has a modules system, and one of the pre-existing modules in the source tree is a `cat` replacement, through my lack of understanding of C prevents me from working out if its optimal
https://git.savannah.gnu.org/cgit/bash.git/tree/examples/loa...