AMAZING! TRY THIS IN WINDOWS! 😀
truncate --size=-1 largefilelike.iso; # cut off last byte of this file
stat -c %s largefilelike.iso; # count again bytes in this file
This actually uses the truncate system call, so it’s efficient and does it without creating a new file.
If you don’t have truncate but have a find with a printf, something like this will work, where find is used to determine the size and the math is done by bash with arithmetic expansion:
or if you have perl, you can have perl do both the filesize calculation and the math:
Although, if you have perl, you can do:
and call the system call directly via perl.