4 ms·
Even though it's not supposed to be my day job, I've ran `df |grep -v <super long list` hundreds of times in the past year, yet it never occurred to me that I c
by tinco 3y ago
Even though it's not supposed to be my day job, I've ran `df |grep -v <super long list` hundreds of times in the past year, yet it never occurred to me that I could try and find a better tool.
- jrm4 3y agoPreach. This happens to me all the time and keeps happening. There's a lot of Unix/Linux stuff that I wish I could UNlearn, I'm aware of other tools but muscle memory keeps me using worse things. (honestly, I also feel this way about vim as well as 'writing in cursive')
- entropie 3y agoI feel you. I still `cat foo | grep bar` instead of `grep foo bar`
- nielsole 3y agoThe reason I stick to `cat foo | grep bar` is that I am never quite sure if `grep bar foo` would be correct instead (it is).
- jrm4 3y agoBut to me -- this is different? I believe "useless use of cat" is FAR MORE useful than what the ultra-nerds say; I could care less about "saving a few characters." The mental model of the pipeline --in one end and out the other -- is entirely too usefully intuitive and way better than some imaginary geek-cred. (I was more thinking about the new rust tools, e.g. rg instead of grep)
- systems_glitch 3y agoPlus sometimes you want to throw something like `pv` in.
- simon04 3y agoPlus the regex is more likely incorrect in the first attempt and needs to be fixed.
- _V_ 3y agoThe former has one big advantage: I can easily change "needle" without having to skip all over the cmdline... Pretty usefull when debugging something interactively.
- MathMonkeyMan 3y agoMight help to replace cat foo | $command with <foo $command It's the same order, but I think $command can sniff what kind of file stdin is, and optimize.
- ezequiel-garzon 3y agoActually instead of `grep bar foo`.
- t-3 3y agoInstalling a new tool just to exclude certain parts of the list has much more friction involved than just making a shell alias/function/script though. It's also much more portable.
- hackmiester 3y agoIf it's possible to include (rather than exclude), you can: $ df /dev/sda1 /dev/nvme0n1p1 And get only those file systems.
- NikkiA 3y agoAnd more importantly, you can specify fs locations, so `df / /home` for example
- gumby 3y ago`df|grep` might be “the better tool” because the cognitive overhead of knowing an extra program’s interface. You’re just saying “show me the subset of this other list” and you automatically select your go-to solution for that: `|grep` The reason for seeking a better tool is when too much excessive work (== time) is involved, or list generation has side effects. But in this case you don’t have two million mount points, so no need to worry.