Solved

extracting a date in a file

Posted on 2000-05-01
4
167 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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…

791 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