I'm learning to use dd
by experimentally playing with its arguments. I would like to create a 10-byte file. I thought the following would work:
dd if=/dev/zero of=./foo count=1 bs=1 obs=9 seek=1
...because of these comments from the man page:
obs=BYTES write BYTES bytes at a time (default: 512) seek=N skip N obs-sized blocks at start of output
...but it does not; it creates a 2-byte file:
>ls -l foo
-rw-rw-r-- 1 user user 2 Mar 28 16:05 foo
My workaround has been:
dd if=/dev/zero of=./foo count=1 bs=1 obs=1 seek=9
But for my learning, I'd like to understand why the first version does not work. Thank you.
bs= 1
andobs=9
conflict, and apparently thebs=
overrides theobs=
specification. Try using the more specificibs=1
instead of thebs=1
. Check the source code to confirm.