I have a few files sized > 1 GB each. I need to remove last few bytes from the files. How can I do it? I prefer to edit file in place to save disk space.
I am on HP-UX.
Try using hexedit I haven't tried it on HP-UX but it should work. It allows you to move to a location in a file and truncate. I'm pretty sure that it does not read the whole file in but just seeks to the appropriate location for display.
Usage is fairly simple once you have launched it the arrow keys allow you to move around. F1 gives help. Ctrl-G moves to a location in the file (hint: to move to end use the size of the file from the bottom row of the display). Position the cursor on the first byte that you want to truncate and then press Escape T once you confirm the truncate will have been done. Ctrl-x exits.
Use a tool that gives you access to the
A Perl version is much more readable: