Dd: Difference between revisions

From Leo's Notes
This page was last edited on 10 April 2017, at 17:02.
Created page with " == Manipulating by Bytes == Use the {{code|iflag=skip_bytes,count_bytes}} flags when working with data in bytes. The {{code|bs}} block size value will be ignored when these f..."
 
m formatting
Line 1: Line 1:


== Manipulating by Bytes ==
== Manipulating by Bytes ==
Use the {{code|iflag=skip_bytes,count_bytes}} flags when working with data in bytes. The {{code|bs}} block size value will be ignored when these flags are used.
Use the {{code|1=iflag=skip_bytes,count_bytes}} flags when working with data in bytes. The {{code|bs}} block size value will be ignored when these flags are used.


Question: When using the {{code|count_bytes}} flag, is this equivalent to {{code|bs=1}}?
Question: When using the {{code|count_bytes}} flag, is this equivalent to {{code|1=bs=1}}?


=== Offset / Skipping Bytes ===
=== Offset / Skipping Bytes ===
Line 9: Line 9:


{{highlight|lang=terminal|code=
{{highlight|lang=terminal|code=
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 | xxd
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 {{!}} xxd
}}
}}


To get only 200 bytes of data instead:
To get only 200 bytes of data instead:
{{highlight|lang=terminal|code=
{{highlight|lang=terminal|code=
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=200 | xxd
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=200 {{!}} xxd
}}
}}


Or 2 kilobytes (2048 bytes):
Or 2 kilobytes (2048 bytes):
{{highlight|lang=terminal|code=
{{highlight|lang=terminal|code=
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=2k | xxd
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=2k {{!}} xxd
}}
}}




[[Category:Linux]]
[[Category:Linux]]

Revision as of 17:02, 10 April 2017

Manipulating by Bytes

Use the iflag=skip_bytes,count_bytes flags when working with data in bytes. The bs block size value will be ignored when these flags are used.

Question: When using the count_bytes flag, is this equivalent to bs=1?

Offset / Skipping Bytes

If you need to extract a chunk of data, say everything past byte 199232000 from a file:

$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 | xxd

To get only 200 bytes of data instead:

$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=200 | xxd

Or 2 kilobytes (2048 bytes):

$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=2k | xxd