- Write programs that do one thing and do it well.
- Write programs to work together.
- Write programs to handle text streams, because that is a universal interface.
I guess none of these apply when reading files is involved?
Looks like people didn’t get the Sublime reference.
You know what? I’m gonna cat into grep even harder now
You can actually change the functionality of some punctuation, such as is used in my favorite command
:():;:
:(){:|:};:What the fork does this even do?
It’s results will blow you away!
Create a function named
:which runs:|:(calls itself and pipes the output to itself). Then it closes the function and uses a semicolon to end the function definition. Next run a command:.TLDR it’s a bash fork bomb
Oh I’m familiar, I was just being punny. Thanks for explaining for those that don’t know, though!
I didn’t know!
Call it for a good time.
I like to alias this to
|… That’s awful, does it work?
Edit: I guess it would need a semicolon or another pipe in the alias
I heard one popular glorp youtuber say “Only glorp hemptets ship into mleb” Bitch I ship into blep all I fucking want, it’s more readable, and I piss whenever I fucking can. I piss two pisses before I piss two pisses, and then I piss more
Yes I know putting two pisses in a row will break your bone. I’ve done it several times before by accident.
implying I give a fuck
Cat outputs your files text and grep searches though that output for occurrences of whatever you feed it. This thing of passing one commands output to another is called piping.
The fuck is a glorp YouTuber?
glorp > fergle, cmv
I think they’re making fun of not understanding the commands involved?
Glorp is the spiritual successor to Fleeb, though mostly ran by the people behind Pumbu (the ones who started it, not the ones who ran it into the ground) and Muupi (the ones who ran it into the ground).
Glorp is on Poob. You can find it on Poob. You can go to Poob and get it. Log onto Poob right now. Go to Poob. Dive into Poob. You can Poob it. It’s on Poob. Poob has it for you. Poob has it for you.
It is for when the processes get krangled.
I think I developed a brain bleed reading this
scerg helps with that choom
Do you pipe two pipes in times of peace, and two in times of war?
Cat into grep lets you insert something between the file read and grep if you need to without having to reorder anything
Which is also exactly what said youtuber said in the same video (assuming this is about who I think it is!).
They also made such reasonable statements as “I also pipe cat into grep when on the command line and playing around with my pipelines, but when it comes to writing full bash scripts to do useful work, think about using grep directly.” (not an exact quote btw!)
I prefer
| lessorless file.txtbecause I can search interactivelyThis is just big small trying to sell more
less, obviously.I prefer
lessuntil I find myself usinglessover and over again until I finally usecatso that I can just scroll up and review whatever I’m looking for.Is it the best or right way to do things? Nope, but it gets the job done just as good as anything else I do.
And, it goes without saying, I do a terrible job of all of it.
what about
$EDITOR <(cat file)?Well, when I can just do
$EDITOR file…The subtle difference is that your $SHELL is responsible for opening (and, iirc, parsing?) the file when you use
\<, versus the $EDITOR being the responsible entity.Oh I get it now.
Also, for some reason settingvias$EDITOR, it is not able to load the contents of the file, unlikevimthat does.
we’re talking about a pipeline(-ish) thing here.
so just out the cmd that you want to read the output of in the brackets
Ok but what is supposed to be bad about grepping into cat? I don’t get it
Edit: thanks for the replies all, I didn’t know you could add a file as an argument in grep. Makes sense now :)
It’s less relatable now, and the technology was fucking stupid to begin with, but: Imagine printing out a document and feeding the sheets into a fax machine instead of just sending the file directly to the machine.
Or using a cassette tape adapter to play music from your phone through a stereo system when that system has a built-in Aux port you could plug directly into (“Useless Use Of Cassette?”).
cat’ing into grep, and a handful of other programs people commonly pipe into from cat, is pointless when grep can be called directly against a file. cat is being run for no reason; a useless use of cat (uuoc). It means fuckall for most people today but I imagine it could’ve been an actual concern when hardware was much more limited and multiple users were connecting to a single system.
The video I saw was saying cat into grep is totally fine in day to day life do whatever comes out of your fingertips naturally, but if you’re making a bash script for others to use, use grep args because cat pipe grep can do some strange stuff with error handling. Which I have no experience with, but sounds reasonable
That does sound reasonable. As I will never write such a script for others, I shall continue to cat into grep.
cat file.txt | grep foois unnecessary and a bit less efficient, because you can dogrep foo file.txtinstead. More generally, using cat into a pipe is less efficient than redirecting the file into stdin with<, likegrep foo < file.txt.Grep can accept input from stdin as with a piped cat, but I it can also just call the file directly.
In 99.999% obviously made up stat is obvious of situations its fine.
The real issue is a piped cat into grep will fork the process. Why open two process threads when one would do the job?
Edit: it was mentioned by
but to expand a bit: piping cat into grep can also mask quite a few errors. It masks them because of how the shell handles error reporting on piped processes. IIRC, if the file is missing for example, you won’t necessarily know that because while cat will throw a not-found error, that gets piped into grep who gladly accepts the error (which was piped to stdin) as its input and greps through the error, reporting back that your content wasn’t found in the search material, not that the file was missing.
cat sends its error via stderr so it won’t go into the pipe (or grep). you will see the cat error on your terminal, unless you have redirected stderr to stdout
What the fork is this forking shirt?
Soz I read your comment as if it were from the good place.
i think the alternative is to use grep args. but ya know i’m living in the future using
nushell’sopencommand and ripgrep so the argument is just kinda adorable
I understood a couple of those words. None of the technical ones, but some of them! They were expletives… But I understood them!
How parsing (as in programming languages and commands) works is so interesting and is so hard for people to grasp and is really interesting to see how what you think is obvious is not for most people. I saw it all the time when teaching cs102. It is so hard to explain the difference that a blank space makes and why sometimes it is necessary and why sometimes it is not.
That is all to say I find it really interesting and funny when OP says double pipe, because of course it looks like double pipe, you gonna tell me That
||is something completely different than a single|?just gotta tee











