Solved

extracting a date in a file

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl search and replace 6 168
pattern matching in perl 2 103
Need to install DBD::MySQL on a MAC without a local MySQL server for Perl 4 55
pipe to sed or perl, please help 5 128
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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

805 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