unix - Appending 0's to make 1MB file with dd -
i have binary file abc.bin 512 bytes long, , need generate 1m (1024 x 1024 = 1048576) byte file appending 0's (0x00) abc.bin. how can dd utility?
for example, abc.bin has 512 bytes of 0x01 ("11 ... 11"), , need have helloos.bin 1048576 bytes ("11 ... 11000 ... 000"); 0 not '0', 0x00, , number of 0x00 1048576 - 512.
you can tell dd seek 1m position in file, has effect of making size @ least 1m:
dd if=/dev/null of=abc.bin obs=1m seek=1 if want ensure dd extends, never truncates file, add conv=notrunc:
dd if=/dev/null of=abc.bin obs=1m seek=1 conv=notrunc if you're on system gnu coreutils (like, linux system), can use truncate command instead of dd:
truncate --size=1m abc.bin if want sure file extended, never truncated:
truncate --size=\>1m abc.bin
Comments
Post a Comment