linux - Different results with cut and dd on binary files -
my environment:
centos 6.5 i need extract part of elf file.
when use dd command follows, have no problem:
$dd if=a.out of=a.cut1 bs=1 skip=16 on other hand, when use cut command follows, created file has less size expected:
$cut --bytes=16- a.out > a.cut2 example, created a.out compiling following sample c program gcc (v. 4.4.7):
#include <stdio.h> int main() { printf("hello world\n"); } then, execute dd , cut commands above, have files following sizes:
a.out - 6415 bytes a.cut1 - 6399 bytes a.cut2 - 6356 bytes i wonder why cut command reduces size more specified.
cut skip first 16 bytes from each line whereas dd doesn't care lines , skips first 16 bytes whole file.
if file contains newlines - valid binary files - cut yield different result dd.
Comments
Post a Comment