Loading ...
Sorry, an error occurred while loading the content.

60715Re: raw fixed width data

Expand Messages
  • Tim Chase
    Aug 2, 2005
      >> sed 's/.\{3\}/&\n/g' infile.txt > outfile.txt
      > I've added newlines with perl before but, I'm hoping to find a
      > "better" solution as these files are sometimes HUGE (Gigabytes) and
      > when making edits repeatedly, a 4 or 5 step process ( copy, add EOLs,
      > edit, remove EOLs, copy back ) can be tedious. So, I'd prefer a
      > solution that would allow "in-place" editing. What I'm looking for is
      > a "record" editor.

      Ah...I didn't gather the frustration of the multiple steps to
      begin with :)

      Vim does allow you to automate some of this, as you can see in the

      :help hex-editing

      This does presume you have access to "xxd". You may be able to
      tweak it to use "xxd -c 3" to spit out 3-column format. however,
      I don't know whether it requires you to edit both the binary and
      the visual goods.

      Alternatively, if you've got your perl script, or the previous
      sed command, or even the previous vim command, you can do the
      same sort of exercise using autocommands:

      augroup Binary
      au BufReadPost *.bin %s/.\{3}/&\r/g
      au BufWritePre *.bin %j!
      au BufWritePost *.bin set nomod
      augroup END

      Seems to do the trick for me, and in a slightly more automated
      fashion than hand cranking it.

      Hope this helps (more), :)

    • Show all 10 messages in this topic