The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl script to add a line into a file karthikn7974 Shell Programming and Scripting 2 06-03-2008 02:11 AM
help on a perl script to edit file meghana Shell Programming and Scripting 9 05-14-2008 03:42 PM
perl script for file processing SEEHTAS Shell Programming and Scripting 10 03-25-2008 09:02 AM
SED/AWK Script to clear log file using timestamp? davesimm Linux 2 03-03-2008 07:18 AM
grep ^M in file using perl script.... zedex Shell Programming and Scripting 12 02-06-2008 08:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-01-2008
biswajeet.beher biswajeet.beher is offline
Registered User
  
 

Join Date: Dec 2007
Location: Baltimore,MD,USA
Posts: 3
Question how to get timestamp of a file in a perl script

I have seen this posting here:

perl -e '@d=localtime ((stat(shift))[9]); printf "%02d-%02d-%04d %02d:%02d:%02d\n", $d[3],$d[4]+1,$d[5]+1900,$d[2],$d[1],$d[0]' file1.txt

I need to use it inside a perl script. Can anybody please help me out.
  #2 (permalink)  
Old 04-01-2008
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
Quote:
Originally Posted by biswajeet.beher View Post
I have seen this posting here:

perl -e '@d=localtime ((stat(shift))[9]); printf "%02d-%02d-%04d %02d:%02d:%02d\n", $d[3],$d[4]+1,$d[5]+1900,$d[2],$d[1],$d[0]' file1.txt

I need to use it inside a perl script. Can anybody please help me out.
Sure. Cut and paste it into your text editor you're using to write the Perl script. Let us know how it turns out.

ShawnMilo
  #3 (permalink)  
Old 04-01-2008
biswajeet.beher biswajeet.beher is offline
Registered User
  
 

Join Date: Dec 2007
Location: Baltimore,MD,USA
Posts: 3
I copied the whole stamenet along with "perl -e"

Thanks, I copied the whole statement into my perl script , but it is giving synatax error:

syntax error at compare_forms2.pl line 27, near "perl -e "

Here is the code i used in my per script:

perl -e '@d=localtime ((stat(shift))[9]); printf "%02d-%02d-%04d %02d:%02d:%02d\n", $d[3],$d[4]+1,$d[5]+1900,$d[2],$d[1],$d[0]
'$ddt_dir_prod[1];

Where $ddt_dir_prod[1] contains a valid file.
  #4 (permalink)  
Old 04-01-2008
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
Either you're joking, or you have no business writing code today. Please pick up a basic Perl book or read a Web tutorial and let us know when you can write a simple Perl script and understand what it does.

Sincerely,
ShawnMilo
  #5 (permalink)  
Old 04-01-2008
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
I apologize for the rudeness of my comment. I know that I sometimes come off more harshly than I mean to, and I also thought that my first post was funny.

But in all seriousness, you don't seem to understand some very basic things, and it wouldn't really help you if we gave you the answers because you wouldn't be able to apply them. Also, you haven't even said what you're trying to accomplish. That makes it nearly impossible for anyone to help you anyway.

If you get anything even half-working, post it and someone may be able to help you fix it. But, as I said, it doesn't appear that you know enough Perl (or maybe programming in general) to be making this attempt without further study.

ShawnMilo
  #6 (permalink)  
Old 04-01-2008
biswajeet.beher biswajeet.beher is offline
Registered User
  
 

Join Date: Dec 2007
Location: Baltimore,MD,USA
Posts: 3
it's ok...i am new to perl

ya u r right. I am very new to this field..as you said have to learn the basic concepts first.Any way thank you very much.
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0