3

What is an equivalent of memmove on files with the same input and output file, which works with large files?

dd works when I move the file contents towards the right, but not if I move the contents left, since there's no handling of overlap.

ddrescue has a reverse copy, but refuses to work on the same input & output file.

  • Is left or right the beginning or end? It can move closer to the beginning but not closer to the end, not without wrapping it in a loop that does it backwards. – frostschutz Mar 21 '14 at 22:48
  • Left is the beginning. – simonzack Sep 1 '14 at 13:19
  • On Linux with some filesystem you could try fallocate – jfs Feb 27 '15 at 13:57
0

beav is a visual binary editor with commands similar to emacs that can edit binary files. The sequence you would use to move a block would run along the lines of :

  • find start of block and set mark ESC.
  • go to to end of block and delete-mark-to-cursor (contents stored in kill-buffer)CTRL-W
  • go to where you want the block moved to and yank CTRLY
  • file-save CTRL-XCTRLS
  • quit CTRL-XCTRLC

Here's the Debian beav package description.

Extract

With beav, you can edit a file in HEX, ASCII, EBCDIC, OCTAL, DECIMAL, and BINARY. You can display but not edit data in FLOAT mode. You can search or search and replace in any of these modes. Data can be displayed in BYTE, WORD, or DOUBLE WORD formats. While displaying WORDS or DOUBLE WORDS the data can be displayed in INTEL's or MOTOROLA's byte ordering. Data of any length can be inserted at any point in the file. The source of this data can be the keyboard, another buffer, or a file. Any data that is being displayed can be sent to a printer in the displayed format. Files that are bigger than memory can be handled.

  • Does beav work with large (multi-terabyte) copy pastes without filling up ram? – simonzack Mar 21 '14 at 10:12
  • You should edit your original question and add that pertinent piece of information. I've added an extract, but haven't tried it with files that large. sorry – X Tian Mar 21 '14 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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