3 ms·
It’s funny (given that the name likely is inspired by Useless Use of ‘cat’) that examples here have actual useless uses of ‘cat’. ‘cat file | pv > disk’ can jus
by salmo 4y ago
It’s funny (given that the name likely is inspired by Useless Use of ‘cat’) that examples here have actual useless uses of ‘cat’. ‘cat file | pv > disk’ can just be ‘pv < file > disk’.
But whatever. I’m sure 90% of code stems from something someone read and copied or came most easily to them. It works.
‘dd’ was really useful for finicky media like tapes and doing EBCDIC translation. It’s still great when you combine bs and count. Blow away an MBR, make an xGB file, etc.
It’s a Swiss Army knife. It can do a lot, but isn’t the best tool for most things. I still love it. Probably just muscle memory.
- hackmiester 4y agoOr just `pv file > disk` ... and then pv will give you a progress bar automatically
- salmo 4y agoOh, good point. When pv sees the actual file vs stdin, it can give % progress without hints. Which is nice. And it’s nicer that the recent ‘dd status=progress’ (if I remember that option right).
- koala_man 4y agoOriginal author here. The intended point was that `dd if=.. | something | dd of=..` is just as useless as the two cats in `cat .. | something | cat > ..`. People sometimes mock the latter while still believing that the former is necessary.
- salmo 4y agoSorry, that came off snarkier than I meant rereading it. You’re 100% correct. I’ve grown more tolerant of these ceremonial uses. There really aren’t many folks that understand shell. I see it in CICD, etc all the time, too. The one left that kills me that I see in vendor scripts all the time is ‘command; ret=$?; if [ “$ret” -ne 0 ]; then foo; fi’ If you’re handling return code cases, then cool. But folks don’t realize ‘test’ aka ‘[‘ is just another command. But then again, so much Java, etc. I read is the same copy/paste. Those can be worse because example code isn’t prod ready, where bad shell usually does the right thing, just awkwardly or inefficiently. But as you point out, so much isn’t thinking about what you’re doing, just mimicking.