Imagine a file created with:truncate -s1T fileecho test >> filetruncate -s2T fileI now have a 2 tebibyte file (that occupies 4kiB on disk), with test\n written in the middle.How would I recover that test efficiently, that is without having to read the whole file.tr -d '\0' < fileWould give me the result but that would take hours.What I'd like is something that outputs only the non-sparse parts of the file (so above only test\n or more likely, the 4kiB block allocated on disk that stores that data).There are APIs to find out which part of the file are allocated (FIBMAP, FIEMAP, SEEK_HOLE, SEEK_DATA...), but what tools expose those?A portable solution (at least to the OSes that support those APIs) would be appreciated.
How to display the non-sparse parts of a sparse file?
text processing;sparse files