Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What other tools should I use to read and write files with truncation, seeking and skipping. dd's command line options seem inconvenient and foreign and I don't like choosing between slow, but precise seeking mode (bs=1) and fast, but inflexible mode (bs=4k or whatever).

Are there more modern tools to read 555 bytes from one file (or pipe or socket or dev) from position 31337 and write them to the other file at position 128205 (using blocks 512+43), with or without truncation?

share|improve this question
I still don't see what is wrong with dd. You could always put a shell script wrapper around it if you don't like the interface. dd is in the POSIX standard, which is a huge plus. – jw013 Jul 31 '12 at 18:55
The main wrong thing is inability to seek to or skip fractional blocks. Second wrong thing that status=noxfer is not default and is broken and that I need iflag=fullblock (omit in some script => broken data). – Vi. Jul 31 '12 at 20:25
You can combine fast-inflexible with slow-precise, e.g. like so: dd bs=1M skip=TO_CHUNK count=1 | dd bs=1 skip=OFFSET. It takes some arithmetic but a wrapper script can deal with that. – Thor Jul 31 '12 at 20:42
1. bs=1 => the whole pipeline is slow. For example I may want to dump video file starting from some exact frame. 2. "It takes some arithmetic" => not very suitable for oneliners and routine shell commands. – Vi. Jul 31 '12 at 20:58
possible duplicate of dd vs cat -- is dd still relevant these days? – Gilles Jul 31 '12 at 23:06

There is the tool ddrescue (watch out, there is also dd_rescue which is a different program with almost the same functionality). It uses the more familiar syntax with the single dash for short or double dash for long options. From the man page:

   -i, --input-position=<bytes>
          starting position in input file [0]

   -K, --skip-size=<bytes>
          initial size to skip on read error [64 KiB]

   -M, --retrim
          mark all failed blocks as non-trimmed

   -o, --output-position=<bytes>
          starting position in output file [ipos]
share|improve this answer
ddrescue - - -> Infile and outfile are the same., ddrescue /dev/stdin /dev/stdout -> Infile and outfile are the same.. Bad beginning of the story... – Vi. Jul 31 '12 at 20:59
I just tried with dd_rescue. It throws a warning that the file (stdin) is not seekable, but proceeds. You can give it a try. However, ddrescue feels more full-featured and mature. – Marco Jul 31 '12 at 21:32
@Vi.: Don't shoot the messenger. ddrescue is right, pipes aren't seekable. If you want to start reading at a specific point in a file, you need to give it access to the file in question, not data piped from another program. Also beware that using pipes fights against this wish of yours for ultimate speed, since the only way to emulate seeking in a pipe is to read and throw away the parts you don't want to process. Seeking within an actual file is far more efficient. – Warren Young Aug 1 '12 at 10:53
Indeed, since the tool is designed for rescuing broken data, there is no pipe capability. This is a bit of a shame when you want the flexibility of seeking through an input file but just want to pipe the result to stdout. For its intended purpose, though, it's great. – PreferenceBean Jun 25 '15 at 12:53

dcfldd is another dd alternative. It doesn't address the OP's question about input/output seek flexibility, but may be useful to others arriving here via google search.

It's based on gnu dd, with the following additional features:

  • Hashing on-the-fly - dcfldd can hash the input data as it is being transferred, helping to ensure data integrity.
  • Status output - dcfldd can update the user of its progress in terms of the amount of data transferred and how much longer operation will take.
  • Flexible disk wipes - dcfldd can be used to wipe disks quickly and with a known pattern if desired.
  • Image/wipe Verify - dcfldd can verify that a target drive is a bit-for-bit match of the specified input file or pattern.
  • Multiple outputs - dcfldd can output to multiple files or disks at the same time.
  • Split output - dcfldd can split output to multiple files with more configurability than the split command.
  • Piped output and logs - dcfldd can send all its log data and output to commands as well as files natively.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.