filesize

Why does “find . -name *.txt | xargs du -hc” give multiple totals?

前提是你 提交于 2019-11-30 09:45:06
I have a large set of directories for which I'm trying to calculate the sum total size of several hundred .txt files. I tried this, which mostly works: find . -name *.txt | xargs du -hc But instead of giving me one total at the end, I get several. My guess is that the pipe will only pass on so many lines of find's output at a time, and du just operates on each batch as it comes. Is there a way around this? Thanks! Alex How about using the --files0-from option to du? You'd have to generate the null-terminated file output appropriately: find . -name "*txt" -exec echo -n -e {}"\0" \; | du -hc -

human readable file size

时光总嘲笑我的痴心妄想 提交于 2019-11-30 01:32:39
function humanFileSize($size) { if ($size >= 1073741824) { $fileSize = round($size / 1024 / 1024 / 1024,1) . 'GB'; } elseif ($size >= 1048576) { $fileSize = round($size / 1024 / 1024,1) . 'MB'; } elseif($size >= 1024) { $fileSize = round($size / 1024,1) . 'KB'; } else { $fileSize = $size . ' bytes'; } return $fileSize; } ... works great except: I can't manually choose in what format I need to display, say i want to show in MB only whatever the file size is. Currently if its in the GB range, it would only show in GB. Also, how do I limit the decimal to 2? Try something like this: function

smallest filesize for transparent single pixel image

我怕爱的太早我们不能终老 提交于 2019-11-29 19:25:13
I'm looking for the smallest (in terms of filesize) transparent 1 pixel image. Currently I have a gif of 49 bytes which seems to be the most popular. But I remember many years ago having one which was less than 40 bytes. Could have been 32 bytes. Can anyone do better? Graphics format is no concern as long as modern web browsers can display it and respect the transparency. UPDATE : OK, I've found a 42 byte transparent single pixel gif: http://bignosebird.com/docs/h3.shtml UPDATE2 : Looks like anything less than 43 bytes might be unstable in some clients. Can't be having that. gmunkhbaatarmn

Finding file size and last modified of SFTP oldest file using Java

无人久伴 提交于 2019-11-29 15:38:24
I'm using JSch to get files from an SFTP server, but I'm trying to figure out a way to only get the oldest file, and to make sure that it is not currently being written to. The way I imagine myself doing this is first finding which file in the specified remote folder is oldest. I would then check the file size, wait x seconds (probably about 10, just to be safe) and then check it again. If the file size has not changed, I download the file and process it. However, I have no idea how to do this! If anybody knows how to do this, or knows of something else that supports SFTP that has this built

Get Large File Size in C

半世苍凉 提交于 2019-11-29 09:55:53
Before anyone complains of "duplicate", I've been checking SO quite thoroughly, but there seem to be no clean answer yet, although the question looks quite simple. I'm looking for a portable C code , which is able to provide the size of a file, even if such a file is bigger than 4GB. The usual method (fseek, ftell) works fine, as long as the file remains < 2GB. It's fairly well supported everywhere, so I'm trying to find something equivalent. Unfortunately, the updated methods (fseeko, ftello) are not supported by all compilers. For example, MinGW miss it (and obviously MSVC). Furthermore,

Maximum size for iOS app

旧街凉风 提交于 2019-11-29 04:17:04
I've read in apple's dev guide there's a limit for iOS app size, but I don't really understand it. It says this: iOS apps can be as large as 2 GB, but the executable file cannot exceed 60 MB. Isn't the executable file the whole app? I don't understand the difference between the 2 GB limit and the 60 MB limit. Samuel Spencer The main part of the app is without a doubt the executable file. The executable is usually not very large, because it's just the compiled code that the machine runs. In small, trivial, apps, this is usually only a few kilobytes (KB). In more complex apps it can make it up

How do I get the size of a file in megabytes using Perl?

早过忘川 提交于 2019-11-29 03:45:11
I want to get the size of a file on disk in megabytes. Using the -s operator gives me the size in bytes, but I'm going to assume that then dividing this by a magic number is a bad idea: my $size_in_mb = (-s $fh) / (1024 * 1024); Should I just use a read-only variable to define 1024 or is there a programmatic way to obtain the amount of bytes in a kilobyte? EDIT: Updated the incorrect calculation. If you'd like to avoid magic numbers, try the CPAN module Number::Bytes::Human . use Number::Bytes::Human qw(format_bytes); my $size = format_bytes(-s $file); # 4.5M You could of course create a

what happens when cookies file exceeds maximum size?

匆匆过客 提交于 2019-11-29 02:52:33
What really happens when cookies file exceeds maximum size? The typical behavior of most browsers, to my knowledge, is to simply truncate the oldest data that does not fit. For example, create cookies 1 through 9. When creating cookie 10 and the data size is going to overflow, cookie 1 is simply discarded. In general practice, if you are worried about bumping into the limit and loosing cookies to overflow, it is probably time to rethink your strategy of what you are storing and start caching the data server-side and limiting the cookie to a value to access the cached data. The file is

H.264 file size for 1 hr of HD video [closed]

柔情痞子 提交于 2019-11-29 01:42:32
I'm looking for an order of magnitude estimate for expected on-disk file size for 1 hour of H.264 encoded HD video transcoded from HDV (HD on a MiniDV tape). I want to archive approximately 100 hours of such content and want to figure out whether I'm looking at a big hard drive, a multi-drive unit like a Drobo, or an enterprise-level storage system. Edit To clarify from several good comments, I am developing the software that will use this archived video and will also manage the transcoding from HDV to compressed format (using QuickTime on OS X). This question is for gathering hardware

Pretty file size in Ruby?

谁都会走 提交于 2019-11-28 19:22:28
I'm trying to make a method that converts an integer that represents bytes to a string with a 'prettied up' format. Here's my half-working attempt: class Integer def to_filesize { 'B' => 1024, 'KB' => 1024 * 1024, 'MB' => 1024 * 1024 * 1024, 'GB' => 1024 * 1024 * 1024 * 1024, 'TB' => 1024 * 1024 * 1024 * 1024 * 1024 }.each_pair { |e, s| return "#{s / self}#{e}" if self < s } end end What am I doing wrong? How about the Filesize gem ? It seems to be able to convert from bytes (and other formats) into pretty printed values: example: Filesize.from("12502343 B").pretty # => "11.92 MiB" http:/