By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,673 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,673 IT Pros & Developers. It's quick & easy.

File size's don't match in terminal vs. file browser window.

P: 66
Hi - I have recently made some changes to a couple C files, and I need to report how much space we have saved in our firmware....

So I used du -kh for file1.c in a UNIX termial and it says 64K for the file size. I then looked at the original file and it ALSO said 64K! So, I opened up the windows to browse the filesystem using icons......and I can compare the two files and the file sizes are: 55.5KB for the original file, and 38.2KB for the modified file.

What is going on here? How can I find the file size without browsing using windows, and WHY is UNIX not correct?

thanks!
Sep 8 '08 #1
Share this Question
Share on Google+
4 Replies

10K+
P: 13,262
Just to be sure, what does ll or ls -al report as the sizes of the files?
Sep 10 '08 #2

Nepomuk
Expert 2.5K+
P: 3,112
Just to be sure, what does ll or ls -al report as the sizes of the files?
... ll being an alias for ls -l. I also find ls -lh useful sometimes, but it would probably be to inaccurate here. (Note: those are all small "L's", not big "i's".)

Greetings,
Nepomuk
Sep 10 '08 #3

ashitpro
Expert 100+
P: 542
You could have used du -b <filename>
this would give you precise size.
When you use du -k <filename>, -k is equivalent to --block-size=1 and it would always give you the answer in terms of block..
Lets say you have file having 9 bytes in it. and assume block size as 4K i.e 4096 bytes.
when you say...
du -b <filename> ans: 9
du -k <filename> ans: 4
du -h <filename> ans: 4k
du -kh <filename> ans: 4k
It would always try to give the output in terms of block size or number of blocks.which would be round figured.
Sep 11 '08 #4

P: 66
Just to be sure, what does ll or ls -al report as the sizes of the files?

> ll
39094

> du -k
64
Sep 11 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.