[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Useful use of dd

On Fri, Jul 02, 2021 at 01:26:23PM +0300, Teemu Likonen wrote:
* 2021-07-02 09:49:23+0200, tomas@tuxteam.de wrote:
FWIW, I've found something which could be deemed to be an "useful use of dd" which somehow bears a hidden symmetry. As a replacement for `cat' whenever you need to put a name on the output file.
For this new subject I will add another use: quickly create empty file of specific size, for example 5 * 1024 bytes: $ dd of=empty obs=1024 seek=5 count=0

For this it is IMO more clear to use truncate:
truncate -s 5k empty

On Fri, Jul 02, 2021 at 07:31:24AM -0400, Greg Wooledge wrote:
On Fri, Jul 02, 2021 at 09:49:23AM +0200, tomas@tuxteam.de wrote:
  sudo dd of=/etc/hosts oflags=append

This appears to be a typo for "oflag=append", which is a GNU extension,
not part of the standard POSIX dd.  No wonder I didn't know about it. ;-)

Because you've been asleep since the 80s when POSIX was relevant? :-D

The bullseye version of GNU coreutils dd also gives a warning message
with this particular flag:

unicorn:~$ echo g | dd of=foo oflag=append
dd: you probably want conv=notrunc with oflag=append
0+1 records in
0+1 records out
2 bytes copied, 9.141e-05 s, 21.9 kB/s

Not sure if that's unique to bullseye.  But anyway, yes, the warning
is accurate; without conv=notrunc, my test file "foo" got overwritten
with just the "g".

It's been like that for more than a decade, sarge in the debian timeline. The warning was added for obvious reasons. :-) (There is a narrow use case for append without notrunc, which is why it's a warning and not a fatal error.)

Reply to: