770 snippets from 1556 members, and growing!
|
login
|
join
about
bytebin
members
tags
snippets
join
Snippets
Submit a Snippet
Search Snippets
New Snippets
Top Snippets
Top Tags
PHP
(136)
JavaScript
(123)
Java
(66)
VBSCRIPT
(58)
String
(44)
CSS
(31)
CSharp
(28)
File
(28)
HTML
(27)
C
(24)
mysql
(24)
VB.NET
(24)
python
(24)
CPlusPlus
(23)
groovy
(23)
New Snippets
Very lightweight ...
AutoComplete plug...
AutoComplete plug...
Connection Java -...
View PostgreSql
Store Procedure
Pygame - Simple p...
Python - Anagram ...
Python - Anagram ...
Converter to bina...
Venture Capital Jobs
New Members
me
jamesmcm
Can
Kelmi
ysg
dannymo2
chorny
wallie
Hackdemian
impomatic
Top Members
dannyboy
sundaramkumar
mattrmiller
Pio
i_kenneth
ASmith
ctiggerf
sehrgut
bertheymans
SCoon
Home
/
Snippets
/
Get a FileSize
Get a FileSize
Snippet Menu
Revisions
Comments
Related Snippets
Add to Favorites
Email Snippet
Download Snippet
Print Snippet
Blog Snippet
snippet
|
revisions
|
comments
|
related
|
Add to Favorites
|
email
download
|
print
|
blog it
7
Mon. Nov. 14th, 2005 7:05 PM
1 of 1
ses5909
File
|
Perl
|
Size
1 comments
Get a FileSize
#to get the filesize, simply do the following:
$filesize
= -
s
(
"/home/www/yourpath/yourfile.txt"
)
;
Sara Smith
www.ilovecode.com
Sara
ilovecode
Comments
New Comment
Another Method
Mon. Oct. 16th, 2006 11:55 AM
snevine
Another method would be to dereference a stat call.
Or even a direct call to stat if you need more information on the file. (No reason to call it twice!)
# NOTE: Taken straight from perldoc
# dereference
my
$size
=
(
stat
(
$fileName
)
)
[
7
]
;
# direct
my
(
$dev
,
$ino
,
$mode
,
$nlink
,
$uid
,
$gid
,
$rdev
,
$size
,
$atime
,
$mtime
,
$ctime
,
$blksize
,
$blocks
)
=
stat
(
$filename
)
;
Reply
New Comment
Voting
Votes Up
ASmith
ctiggerf
dannyboy
i_kenneth
Pio
snevine
sundaramkumar
wiz1705
Votes Down
lolfejs
Or even a direct call to stat if you need more information on the file. (No reason to call it twice!)
# NOTE: Taken straight from perldoc
# dereference
my $size = (stat($fileName))[7];
# direct
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);