stat command filesize reporting on busybox
I'm trying to write a shell script in busybox to check the filesize of a file. Having read that stat is more reliable then ls, I decided to use that, but somehow when using the following command:
stat -c %s filename
I get the following output: 559795. This goes for the following 2 files (shown using ls -la):
0 Jan 20 16:32 foo_empty
4 Jan 20 16:32 foo_not_empty
Anyone know what's happening there? I can just go back to using ls, but I'm not understanding what's happening here, and that's bothering me..
Solution 1:
if stat is reporting the same odd number for filesize, number of blocks, inode, and device. I'd suspect filesystem corruption. You might try fsck and see if it finds/fixes problems.