HI version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
33% Positive
Analyzed from 991 words in the discussion.
Trending Topics
#file#cat#piping#command#more#less#process#files#grep#awk

Discussion (41 Comments)Read Original on HackerNews
Program A might accept a file as the last positional arg. Program B might accept it as a named arg, where the name/flag could be anything from --input or -f or --file etc.
But a program will read from STDIN, which all good unix programs do, then piping cat into it works every time. I can write the cat foo.txt part before I even know what command I'm piping it into.
I've probably lost 10ms * 1E5 of my life from the extra PID. But, probably would lose more in the context switch.
You know what? I'll tell you another thing I do that's similar:
Always bugged me that you say WHERE for the first one and AND thereafter, so if I'm poking around the database trying to create actionable insights for key stakeholders at the speed of business just as I was above with the text file, I like to be able to futz and delete/add clauses as I see fit just as I do pipeline stages."Oh no, it spawns another process!!" Again, nobody cares.
Chrome probably spawned two processes when I cmd+clicked this into a new tab. It really doesn't matter.
Personally, when I'm exploring, I build a command line iteratively. Cat the file to see the content, pipe to grep to get the lines I want, sed/awk/cut/etc to finagle from there.
(who gives even a single shit, my god)
Edit: for context my home router is a TP Link and for some reason it has IPv6 disabled completely and I'm too scared to enable it.
http://catb.org/jargon/html/U/UUOC.html
Admittedly its taken me a long time to remember that the file is the last argument to grep, when so many other commands its the first. I'd guess common abuse is due to being easier to type cat x | than to dig up the man page
`alt + .` is much more versatile. You can use it to cycle through and insert the last arguments of previous commands.
I guess the file is usually the last argument because it's the one that can be omitted.
When you're building a pipeline, putting cat first can often be quite convenient. Essentially, it's more composable: it defines the input to the pipeline without committing to a specific tool. For example, you can up-arrow in the shell and change the part after the pipe without having to skip back past the filename.
In fact if you don't start with cat, it's possible you're more of a script kiddie than a software developer.
- various HostGator employees, c. 2011
Now for firefox:
Maybe people should be looking at that ? I will not even get into modern Linux Desktops :)< file grep abc