“Well why does the entire internet say to use dd then?”
Because they copy from each other just like you copied from them. Just use cat.
“Well why does the entire internet say to use dd then?”
Because they copy from each other just like you copied from them. Just use cat.
We’ve gone full circle.
https://en.m.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_ca...
Anything after the "cat file |" can't overwrite the file.
cat file | cat > file
(This won't, as you might hope, leave the file unchanged.)Re-read what you typed before hitting enter, and keep backups of important things.
More likely is you are messing around with some new/infrequently used utility and you pass in the arguments incorrectly and specify "file" as the output instead of the input as intended.
At the end of the day do whatever pattern works for you - for me it's doing "cat file |" at the start of a pipeline and "> outfile" at the end.
I also avoid globbing inside a pipeline as it can be dangerous too.
Great statement. This brings me some much needed internal clarity on my own thoughts and actions.
https://www.executiveforum.com/cutting-off-the-ends-of-the-h...
tl;dr nobody in 2 generations knows why they cut the ends off the ham before cooking it, until they talked to grandma, who said her pan was too small
A Unix thing that's been posted to HN for a decade, that's almost literally the same story:
Understanding the bin, sbin, usr/bin , usr/sbin split
https://news.ycombinator.com/item?id=3519952
tl;dr /usr/bin is separate from /bin because someone had a small hard disk once
There was a problem about integrating support for different compression applications, with each one needing to get a new letter in the tar command!
x - extract
z - gzip format
f - file (must be last so it parses the filename arg correctly
I also add "vv" in the middle so it lists every file as it goes, so I can see it work instead of just waiting with no output.
I just tried to copy an ISO to a USB drive with `rsync`, and it didn't work.
Looking it up, I read these comments[0]:
"rsync operates on files which are on a filesystem. It doesn’t do comparisons between blocks. If you want to back up a block device to a file, use dd"
"I completely understood the use case. rsync (still) does not operate on block devices, so it’s not the solution here."
"Agreed, rsync has never operated on block devices."
So I thought, "Ah. There's File Data, which is what `rsync` deals with, and RAW BLOCK data, which is what scary hardcore tools like `dd` deal with."
Then the notion that `cp` and `cat` can deal with both species of data is confusing. :p
0: https://old.reddit.com/r/linuxadmin/comments/eappzm/rsync_bl...
Because you usually need root to write to drives, and you can't `sudo` redirect. `sudo dd if=whatever.img of=/dev/whatever` is nicer and easier than `sudo sh -c "cat whatever.img >/dev/whatever"`.
Your example would then become something like...
cat whatever.img | sudo tee /dev/whatever > /dev/null # https://stackoverflow.com/questions/82256
Just like in household plumbing, the 'tee' command basically takes the input and sends it to more than one place. Naturally, running 'sudo tee' will let you send things all over but as another user.
All that said, I won't speak to the comment "why does the entire internet say to use dd". I've never actually found the "whole internet" to agree on much of anything (-:
UNIX’s simplicity of “everything is a file” continues to surprise me, even though it shouldn’t any more. I think a lack of confidence in my understanding of the basics, leaves me tempted to copy from others as you mention.
That said if you don't know whether or not you need it, you don't. And those who do would know not to listen to your advice (for what they need to do) anyway, so it's not bad general advice to give.