this post was submitted on 15 Dec 2025
311 points (98.4% liked)

linuxmemes

28444 readers
1518 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
  • Don't get baited into back-and-forth insults. We are not animals.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn, no politics, no trolling or ragebaiting.
  • Don't come looking for advice, this is not the right community.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
  • 5. πŸ‡¬πŸ‡§ Language/язык/Sprache
  • This is primarily an English-speaking community. πŸ‡¬πŸ‡§πŸ‡¦πŸ‡ΊπŸ‡ΊπŸ‡Έ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
  • 6. (NEW!) Regarding public figuresWe all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.
  • Keep discussions polite and free of disparagement.
  • We are never in possession of all of the facts. Defamatory comments will not be tolerated.
  • Discussions that get too heated will be locked and offending comments removed.
  • Β 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.

    founded 2 years ago
    MODERATORS
    you are viewing a single comment's thread
    view the rest of the comments
    [–] dabaldeagul@feddit.nl 15 points 22 hours ago* (last edited 16 hours ago) (5 children)

    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 :)

    [–] __hetz@sh.itjust.works 8 points 16 hours ago

    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.

    [–] swicano@programming.dev 16 points 21 hours ago (1 children)

    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

    [–] SaharaMaleikuhm@feddit.org 1 points 5 hours ago

    That does sound reasonable. As I will never write such a script for others, I shall continue to cat into grep.

    [–] expr@programming.dev 17 points 21 hours ago* (last edited 21 hours ago)

    cat file.txt | grep foo is unnecessary and a bit less efficient, because you can do grep foo file.txt instead. More generally, using cat into a pipe is less efficient than redirecting the file into stdin with <, like grep foo < file.txt.

    [–] ArsonButCute@lemmy.dbzer0.com 18 points 22 hours ago* (last edited 15 hours ago) (2 children)

    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 @swicano@programming.dev 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.

    [–] CallMeAl@piefed.zip 1 points 2 hours ago

    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

    [–] witty_username@feddit.nl 5 points 20 hours ago

    What the fork is this forking shirt?

    Soz I read your comment as if it were from the good place.

    [–] chrash0@lemmy.world 2 points 22 hours ago

    i think the alternative is to use grep args. but ya know i’m living in the future using nushell’s open command and ripgrep so the argument is just kinda adorable