Solved

extracting a date in a file

Posted on 2000-05-01
4
161 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
Comment Utility
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
Comment Utility
Adjusted points from 50 to 100
0
 

Author Comment

by:kaleid
Comment Utility
Thank you maneshr, much appreciated.
0
 
LVL 16

Expert Comment

by:maneshr
Comment Utility
anytime... most welcome :-)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
perl rename 2 137
Passing shell scripts to run on the SFTP cmd object 12 174
Strange perl issue 6 122
Exchange 2010 Transport Rule Regex 28 88
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now