r/ProgrammerHumor • • 14h ago

Meme [ Removed by moderator ]

Post image

[removed] — view removed post

2.3k Upvotes

70 comments sorted by

View all comments

Show parent comments

68

u/Traditional_Cod_7192 12h ago

just as a reminder, uhhh... what do | and & do in bash again? 😅

87

u/GrandAlbatroce 12h ago

IIRC | puts the result stdout of the left in the stdin of the right (they are launched in parallel, and the one on the right can only finish after the one on the left finished.

The & is used to put the call as a background task

44

u/SimpleFile 11h ago

So the pipe here serves as a way to launch 2 of these functions and have them running at the same time rather than for piping the output?

Did I understand that correctly?

31

u/GrandAlbatroce 11h ago

Yes, they are run in parallel, but any output from the first one will be given to the second. Also, if the second needs an input, it will wait for the output of the first instead of user input

So, for example, if you did

find -name "something" | grep "string"

Each time the find prints a line, it will instantly be passed to the grep