1

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.

3
  • bs= 1 and obs=9 conflict, and apparently the bs= overrides the obs= specification. Try using the more specific ibs=1 instead of the bs=1. Check the source code to confirm.
    – sawdust
    Mar 29, 2017 at 1:25
  • @sawdust You're correct: thanks for the tip. Please post as an answer if you'd like the point.
    – StoneThrow
    Mar 29, 2017 at 1:44
  • crosspost of unix.stackexchange.com/questions/354460/…
    – quixotic
    Mar 29, 2017 at 1:53

1 Answer 1

3

Your simultaneous use of bs= 1 and obs=9 conflict, since the bs parameter specifies both input and output block sizes.
Apparently the bs= overrides the obs= specification.

Try using the more specific ibs=1 instead of the bs=1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .