Solved

extracting a date in a file

Posted on 2000-05-01
4
169 Views
Last Modified: 2010-03-05
how would you go about extracting the date of and file size from files?
0
Comment
Question by:kaleid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 100 total points
ID: 2767104
you can use the stat function of PERL to do get the size of the file.

however you cant directly get the date of the file. you can only get the Last access time, Last modification time & File creation time in seconds.

This function returns a 13-element list giving the statistics for a file, either the file opened via FILEHANDLE, or named by EXPR.
It's typically used as follows:

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,    $atime,$mtime,$ctime,$blksize,$blocks) = stat $filename;

here is a sample script that shows you how.

===file_sz.pl
#!/usr/local/bin/perl

$file="/tmp/test.pl";

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
    $atime,$mtime,$ctime,$blksize,$blocks)
            = stat $file;

print "file size is $size\n";

##Last access time, Last modification time & File creation time in seconds.
print "$atime $mtime ctime\n";
0
 

Author Comment

by:kaleid
ID: 2775043
Adjusted points from 50 to 100
0
 

Author Comment

by:kaleid
ID: 2775044
Thank you maneshr, much appreciated.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2775062
anytime... most welcome :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl 101 11 91
use google analytics code in perl script 2 101
How to translate this 2-line while loop into C from Perl? 8 165
Use Perl to Remove Large Quantity of Files Quickly 8 28
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question