working on this unix redirects diagram today
Conversation
Notices
-
Embed this notice
Julia Evans (b0rk@social.jvns.ca)'s status on Friday, 22-Nov-2024 05:00:11 JST Julia Evans -
Embed this notice
Peter Krefting (nafmo@social.vivaldi.net)'s status on Friday, 22-Nov-2024 06:25:32 JST Peter Krefting @b0rk If you're covering bash, there are also some other interesting syntax to consider, such as "cat <<<string" and "<(command)", which is not a redirect at all (but incredibly useful, I tend to compare commits using "meld <(git show A) <(git show B)"). There is a corresponding ">(cmd)" syntax that I haven't quite understood myself yet.
And there is also the confusing case of "sudo ls > foo.txt" which is a bit confusing as to which user it is that writes to foo.txt (use "sudo tee" to write as super-user).
-
Embed this notice
Peter Krefting (nafmo@social.vivaldi.net)'s status on Friday, 22-Nov-2024 06:29:06 JST Peter Krefting @njvack @b0rk There's a minor difference in that in the first case, cmd's file 0 is file.txt, whereas in the second case it is a pipe that will get the contents of file.txt.
If the file is very large, you might notice a difference in memory usage for the pipe, but for most intents and purposes it shouldn't matter (but the < file.txt form is both less typing and more efficient).
-
Embed this notice
Nate Vack 🍴 (njvack@ruby.social)'s status on Friday, 22-Nov-2024 06:29:07 JST Nate Vack 🍴 @b0rk I always forget `cmd < file.txt` and use `cat file.txt | cmd` which I suspect is different in subtle but occasionally important ways
-
Embed this notice
Elias (eliasr@social.librem.one)'s status on Friday, 22-Nov-2024 12:29:41 JST Elias @b0rk nice! I was confused by the last two parts at first but now I get it: cmd2 is grep 😃
-
Embed this notice
Tobias Hellgren (thanius@mastodon.chuggybumba.com)'s status on Friday, 22-Nov-2024 17:06:06 JST Tobias Hellgren @b0rk Nice! Have you seen mermaid.live btw?
-
Embed this notice