Find file size using perl
Find file size using perl
Find file size using perl
and display it in KB (Kilo Bytes). You need to provide the name of the file which the size needs to be checked as an argument and the script will return it size accordingly in Bytes and Kilo Byte(KB).
#!/usr/bin/perl -w $filename = $ARGV[0]; if(@ARGV == 0) { print "Please pass the name of file as an argument to check its size\n"; exit; } $filesize = -s $filename; if ($filesize == 0) { print "File Size Is Zero"; } else { print "Size of the file $ARGV[0] is ".$filesize/1024 ." Bytes\n"; print "Size of the file $ARGV[0] is ".$filesize/1024 ." KB\n"; }