If you ever need to get lsusb info but have too many devices, doing diff <(lsusb) <(sleep 3; lsusb) will show you the device, you just need to plug it in in the span of 3 seconds after hitting enter. Adjust according to the level of clumsiness and/or average number of the rotations of the connector needed.
nice explanation! one minor thing: those items in /proc aren't temp files, per se, they're named pipes used to provide input to or output from the substituted command. unlike redirection, the data written to or read from the pipe could come from multiple processes.
I use Unix since the early 90s and this stuff STILL blows my mind ... awe and wonder. Just learning and applying it "poorly" makes me feel smarter, but the mad bunch of lads and lasses who came up with this all are total legends. By the way, sed is great and all, but if you want less typing then "tr" is pretty neat for simple string replacements.
I was always mocked during my young years for using shell, 25 years later shell keeps being my main tool, it is great young individuals keeps finding shell fun and powerful π
"Check that everything I want to replace is what I want to replace" - I've heard of someone who needed to change the anonymized names in their PhD thesis from Phil to clay. Well, you can imagine how embarrassing it was for them to have handed in a PhD thesis on Clayosophy π
I spent 25 years working in the industry with sysadmins, hackers, top level engineers, and I've not come across this at all. You can't imagine how much this just hurt my brain because years we wasted piping stuff around and waiting for transfers to complete.
Don't feel bad. In my 40 yr career in IT (30 in Unix/linux) I never saw a command like that. I'll have to rewatch this to wrap my head around it. Well done!
In zsh you can use =(cmd) instead of <(cmd) to make an actual file in /tmp instead of a pipe in /proc. This way the process you pass it to can read/write it multiple times instead of exhausting the stream then causing a broken pipe error
I've been daily driving Linux for work for over a decade and you always teach me something new and interesting. Loving this channel π may the algorithm gods smile upon you
I think, it can be useful to understand what is happening with `ls -l >(cat)`. The `>()` is a process substitution; in our case we use `>(cat)`, the shell:
- starts `cat` as a separate process - creates a pipe (or FIFO) - connects `stdin` of `cat` to the read end of that pipe - replaces `>(cat)` on the command line with a filename that refers to the write end of that pipe
What you see is not output of the `cat` but `ls` directly, as it got passed the path to the file-descriptor pointing to that pipe (one can verify by replacing `cat` with something else).
wanna see some vim tricks? https://www.youtube.com/watch?v=pyV3SEIWsKQ
couldn't decide on a wallpaper so I made a collage. (free) download if you wish - https://www.patreon.com/breadonpenguins