EmbLogic's Blog

Using dd command to Convert a file

dd—Convert a file while copying it (data dumper)


dd [—help] [—version] [if=file] [of=file] [ibs=bytes] [obs=bytes] [bs=bytes]
[cbs=bytes] [skip=blocks] [seek=blocks] [count=blocks] [conv={ascii,
ebcdic, ibm, block, unblock, lcase, ucase, swab, noerror, notrunc, sync}]


The GNU version of dd copies a file (from the standard input to the standard output, by default) with a user-selectable blocksize, while optionally performing conversions on it.


Numbers can be followed by a multiplier:
b=512, c=1, k=1024, w=2, xm=number m

These options are available:
—help Print a usage message on standard output and exit successfully.
—version Print version information on standard output then exit successfully.
if=file Read from file instead of the standard input.
of=file Write to file instead of the standard output. Unless conv=notrunc is given, truncate
file to the size specified by seek= (0 bytes if seek= is not given).
ibs=bytes Read bytes bytes at a time.
obs=bytes Write bytes bytes at a time.
bs=bytes Read and write bytes bytes at a time. Override ibs and obs.

cbs=bytes Convert bytes bytes at a time.
skip=blocks Skip blocks ibs-sized blocks at start of input.
seek=blocks Skip blocks obs-sized blocks at start of output.
count=blocks Copy only blocks ibs-sized input blocks.
conv=conversion[,conversion...] Convert the file as specified by the conversion arguments.


ascii Convert EBCDIC to ASCII.
ebcdic Convert ASCII to EBCDIC.
ibm Convert ASCII to alternate EBCDIC.
block Pad newline-terminated records to size of cbs, replacing newline with trailing spaces.
unblock Replace trailing spaces in cbs-sized block with newline.
lcase Change uppercase characters to lowercase.
ucase Change lowercase characters to uppercase.
swab Swap every pair of input bytes. Unlike the UNIX dd, this works when an odd
number of bytes are read. If the input file contains an odd number of bytes, the last
byte is simply copied (since there is nothing to swap it with).
noerror Continue after read errors.
notrunc Do not truncate the output file.
sync Pad every input block to size of ibs with trailing NULLs.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>