As PHP’s file_size doesn’t work on directories without write permissions (yes… very odd) I was looking for a workaround using exec/parsing the results.
So I basically want just a list of filenames/size in bytes for easy parsing.
ls -l
Does what I want aside from the useless additional information in there. ls -1 -A -s -h
Gives the size in KB/MB etc, bit difficult to parse ls -1 -A -s
Gives size in blocks, but need root permissions to figure out the blocksize? filesize [FILENAME]
Works great, but only one file a time? Probably going to be rather slow with a lot of files in one directory. Tried **filesize *** and **filesize *** but both give back the result of just one file.
Why not just use du? By default I think it gives you kilobytes but ‘-b’
will have it return bytes.
du -b /path/to/your/file
Good luck.
Axeia wrote:
> Hi
>
> As PHP’s file_size doesn’t work on directories without write
> permissions (yes… very odd) I was looking for a workaround using
> exec/parsing the results.
> So I basically want just a list of filenames/size in bytes for easy
> parsing.
>
> ls -l
> Does what I want aside from the useless additional information in
> there.
> ls -1 -A -s -h
> Gives the size in KB/MB etc, bit difficult to parse
> ls -1 -A -s
> Gives size in blocks, but need root permissions to figure out the
> blocksize?
> filesize [FILENAME]
> Works great, but only one file a time? Probably going to be rather slow
> with a lot of files in one directory. Tried *filesize ** and *filesize
> ** but both give back the result of just one file.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
On Wed, 2009-04-29 at 18:16 +0000, Axeia wrote:
> Hi
>
> As PHP’s file_size doesn’t work on directories without write
> permissions (yes… very odd) I was looking for a workaround using
> exec/parsing the results.
> So I basically want just a list of filenames/size in bytes for easy
> parsing.
>
> ls -l
> Does what I want aside from the useless additional information in
> there.