1) Logical step 1. How do I get the time in perl? I guess wildly and try perldoc -f time That returns it in seconds. A start.
2) Logical step 2. How can I convert that into something I can use? Well, the 'time' function documentation suggests the localtime function and perldoc -f localtime suggests the strftime function and the POSIX module and even gives examples. time isn't needed apparently since localtime calls it implicitly unless you give it otherwise. man strftime also tells you what strings strftime needs.
3) Logical step 3. How can I open a string as a filename? The same way you open any other filename. perldoc -f open
So you get
I knew none of this by heart, I just followed the trail of instructions.
Answer so detailed like this is really great.
There's a Chinese proverb that reads: "授人以鱼, 不如授人以渔", which means "If you give him a fish, he'll only have a single meal, if you teach him to fish, he will feed himself for his whole life.".
Dear Expert,
Is there a command to do that in Unix?
In such a way that we don't need to actually "write" or
modified the content.
-- monkfan (4 Replies)
Hi All,
I need to get file creation date.
I have to access one file who's name is like...
abc.log092308
and the date changes as per current date. And i am accessing this file next day. meance in above case i will access above file on 09-24-2008
Also one problem is that this file... (2 Replies)
I want to gzip a file and append the creation date to the end of the file. How can I accomplish this task. Basically they are log files which need a creation date stamp appended to make sure they do not overwrite other log files.
-jack (3 Replies)
Hi,
I just need to know way of getting date of file when it was created.
eg i have a file abc created on 23 aug. Now i need to know date of file i.e. 23 aug. How can i get that data.
Thanks
Sarbjit (7 Replies)
Hi,
Can anyone tell me a process to find the creation date of a file in a directory.
If suppose I have a file in a directory created in 2009
-rw-r--r-- 1 xyz guest 2480 Jul 16 2009 sample.txt
The command should return the the file creation date as 16/07/2009
thanks, (2 Replies)
The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Hi guys,
I had a scenario...
1. I had to get the previous days date in yyyymmdd format
2. i had to create a file with Date inthe format yyyymmdd.txt format
both are different
thanks guys in advance.. (4 Replies)
Hello ,
I am looking for a script to print file name and its last updated time.
FILE CREATION-TIME FILE-NAME
24/10/2017 12:34 TDR-IU-8-2017.10.24.07:40:00-2017.10.24.07:45:00
when we run l command it print the directory and the files with details like permission,... (1 Reply)
Hello Folks,
I have an requirement, where i need to get total count of the file based on creation date with there filename selected pattern.
Filename: MobileProtocol.20171228T154200.157115.udr
I want to get the count of files created on each day based on a pattern find.
find . -type... (7 Replies)
Discussion started by: sadique.manzar
7 Replies
LEARN ABOUT LINUX
date::format
Date::Format(3pm) User Contributed Perl Documentation Date::Format(3pm)NAME
Date::Format - Date formating subroutines
SYNOPSIS
use Date::Format;
@lt = localtime(time);
print time2str($template, time);
print strftime($template, @lt);
print time2str($template, time, $zone);
print strftime($template, @lt, $zone);
print ctime(time);
print asctime(@lt);
print ctime(time, $zone);
print asctime(@lt, $zone);
DESCRIPTION
This module provides routines to format dates into ASCII strings. They correspond to the C library routines "strftime" and "ctime".
time2str(TEMPLATE, TIME [, ZONE])
"time2str" converts "TIME" into an ASCII string using the conversion specification given in "TEMPLATE". "ZONE" if given specifies the
zone which the output is required to be in, "ZONE" defaults to your current zone.
strftime(TEMPLATE, TIME [, ZONE])
"strftime" is similar to "time2str" with the exception that the time is passed as an array, such as the array returned by "localtime".
ctime(TIME [, ZONE])
"ctime" calls "time2str" with the given arguments using the conversion specification "%a %b %e %T %Y
"
asctime(TIME [, ZONE])
"asctime" calls "time2str" with the given arguments using the conversion specification "%a %b %e %T %Y
"
MULTI-LANGUAGE SUPPORT
Date::Format is capable of formating into several languages by creating a language specific object and calling methods, see Date::Language
my $lang = Date::Language->new('German');
$lang->time2str("%a %b %e %T %Y
", time);
I am open to suggestions on this.
CONVERSION SPECIFICATION
Each conversion specification is replaced by appropriate characters as described in the following list. The appropriate
characters are determined by the LC_TIME category of the program's locale.
%% PERCENT
%a day of the week abbr
%A day of the week
%b month abbr
%B month
%c MM/DD/YY HH:MM:SS
%C ctime format: Sat Nov 19 21:05:57 1994
%d numeric day of the month, with leading zeros (eg 01..31)
%e like %d, but a leading zero is replaced by a space (eg 1..32)
%D MM/DD/YY
%G GPS week number (weeks since January 6, 1980)
%h month abbr
%H hour, 24 hour clock, leading 0's)
%I hour, 12 hour clock, leading 0's)
%j day of the year
%k hour
%l hour, 12 hour clock
%L month number, starting with 1
%m month number, starting with 01
%M minute, leading 0's
%n NEWLINE
%o ornate day of month -- "1st", "2nd", "25th", etc.
%p AM or PM
%P am or pm (Yes %p and %P are backwards :)
%q Quarter number, starting with 1
%r time format: 09:05:57 PM
%R time format: 21:05
%s seconds since the Epoch, UCT
%S seconds, leading 0's
%t TAB
%T time format: 21:05:57
%U week number, Sunday as first day of week
%w day of the week, numerically, Sunday == 0
%W week number, Monday as first day of week
%x date format: 11/19/94
%X time format: 21:05:57
%y year (2 digits)
%Y year (4 digits)
%Z timezone in ascii. eg: PST
%z timezone in format -/+0000
%d, %e, %H, %I, %j, %k, %l, %m, %M, %q, %y and %Y can be output in Roman numerals by prefixing the letter with "O", e.g. %OY will output
the year as roman numerals.
LIMITATION
The functions in this module are limited to the time range that can be represented by the time_t data type, i.e. 1901-12-13 20:45:53 GMT to
2038-01-19 03:14:07 GMT.
AUTHOR
Graham Barr <gbarr@pobox.com>
COPYRIGHT
Copyright (c) 1995-2009 Graham Barr. This program is free software; you can redistribute it and/or modify it under the same terms as Perl
itself.
perl v5.10.1 2009-12-12 Date::Format(3pm)