CLI with style?

Feb 25, 2011
17,000
1,628
126
So, I came across in a shell script while I was tinkering:

bash -c 'cat src/build/images/amd64-generic/R39-6242.0.2014_09_07_0823-a1/chromiumos_image.bin | dd of=/dev/sdb bs=4M iflag=fullblock oflag=sync'

Is there an advantage to doing it this way as opposed to just specifying an "if=" in the dd command? (Is it maybe more shell-agostic or something?)
 

Jodell88

Diamond Member
Jan 29, 2007
8,762
30
91
I'll just preface my response with I've never used dd.

From what I understand, the "if=" command can be used for what you're attempting to do. However, make sure "if=" is put before "of=" otherwise dd will live up to its nickname of "data destroyer". :D
 

lxskllr

No Lifer
Nov 30, 2004
60,927
11,260
126
I'll just preface my response with I've never used dd.

From what I understand, the "if=" command can be used for what you're attempting to do. However, make sure "if=" is put before "of=" otherwise dd will live up to its nickname of "data destroyer". :D

I've always used if=, but I also don't use dd much. When I use it, I check and double check everything so I don't make a bad mistake.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
I think it was written like that because it was in a shell script. Using the "if=" command is more common and will achieve the same thing.
 

LCTSI

Member
Aug 17, 2010
93
0
66
`cat` uses 4KiB buffers by default and is a little more efficient than `dd` because it doesn't use memcpy. It can be possible that the args for your `dd if=` are not optimal for the destination `of=`, so you separate them by a pipe. And in those cases, among others,`cat` can be better for the situation than `dd`.

If you're interested in the performance delta, for each method you can clear the system cache and time the run, to compare.
 

jhu

Lifer
Oct 10, 1999
11,918
9
81
Why not:

cat src/build/images/amd64-generic/R39-6242.0.2014_09_07_0823-a1/chromiumos_image.bin > /dev/sdb

Does this not give a similar result?
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
Why not:

cat src/build/images/amd64-generic/R39-6242.0.2014_09_07_0823-a1/chromiumos_image.bin > /dev/sdb

Does this not give a similar result?

It will, but he will miss the arguments "bs=4M iflag=fullblock", which might differ using the cat command.