du और Finder एक ही फ़ोल्डर का अलग-अलग साइज़ क्यों दिखाते हैं
किसी फ़ोल्डर पर du -sh चलाएँ और उसे Finder के साइज़ से मिलाएँ, तो दोनों अक्सर अलग निकलते हैं, कभी-कभी कई गीगाबाइट का फ़र्क़। दोनों में से कोई ग़लत नहीं है। वे अलग सवालों का जवाब देते हैं: फ़ाइलें कितनी लंबी हैं, और वे डिस्क की कितनी जगह घेरती हैं। डिस्क भर जाने पर सिर्फ़ दूसरा सवाल मायने रखता है, और उसे सही निकालने के लिए सिर्फ़ st_size जोड़ना काफ़ी नहीं है। नीचे के नियम osFoundry डेस्कटॉप ऐप की…
The differences in file size reported by du and Finder can be attributed to the distinct methods they use in calculating file sizes. Du stands for "disk usage," and it counts the number of 4 KB allocation blocks on APFS volume that a file occupies. This means that even if a file is not fully filled with data, the disk block it occupies is still counted in du's calculations.
In contrast, Finder shows the size of a file based on the actual bytes of data it contains. So, for a small file like a 2-byte text file, Finder will display its size as 2 bytes, while du will show it as 4 KB due to the block allocation.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.