Is it possible to truncate a file (in place, same inode) at the beginning?
11
votes
9
answers
7550
views
It is possible to remove trailing bytes of a
file
without writting to a new file ( > newfile
) and moving it back (mv newfile file
). That is done with truncate
:
truncate -s -1 file
It is possible to remove leading bytes but by moving it around (which changes the inode) (for some versions of tail):
tail -c +1 file > newfile ; mv newfile file
So: How to do that without moving files around?
Ideally, like truncate, only a few bytes would need to be changed even for very big files.
note: sed -i
will change the file inode, so, even if it may be useful, is not an answer to this question IMO.
Asked by user232326
Nov 30, 2019, 05:25 PM
Last activity: Dec 11, 2019, 06:14 AM
Last activity: Dec 11, 2019, 06:14 AM