Sponsored Content
Full Discussion: N days ago
Top Forums UNIX for Advanced & Expert Users N days ago Post 302489640 by radoulov on Friday 21st of January 2011 04:16:16 AM
Old 01-21-2011
Code:
perl '-MPOSIX qw(strftime)' -le'
  print strftime "%a %b %e %H:%M:%S %Y", 
    localtime time - 86400 * shift;
  ' <n>

For example:

Code:
% perl '-MPOSIX qw(strftime)' -le'
  print strftime "%d%m%y", localtime time - 86400 * shift;
  ' 5
160111

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting files created before two days ago

Dear All: I want to build a shell that delete files created two or more days ago ... I think it could be built using a special command with ls or grep, I'd apreciate any help from you guys I have a lot of log files from november, december, january and this tool will help me a lot The files... (3 Replies)
Discussion started by: josecollantes
3 Replies

2. Shell Programming and Scripting

Function 7 days ago

Please tell me how can I wirte a function to return the date 7 days ago by using calendar command? :confused: (2 Replies)
Discussion started by: LAY
2 Replies

3. UNIX for Dummies Questions & Answers

file was created before 15 days ago.

How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago? It has to be korn shell script. Thanks. (1 Reply)
Discussion started by: YoungBlood
1 Replies

4. Shell Programming and Scripting

Find the file from 15 days ago

How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago? It has to be korn shell script. Thanks. (2 Replies)
Discussion started by: YoungBlood
2 Replies

5. Shell Programming and Scripting

date for two days or 3 days ago

i need a script that can tell me the date 2 days ago or 3 days ago. please help (7 Replies)
Discussion started by: tomjones
7 Replies

6. Shell Programming and Scripting

Date within a timeframe 2 days ago

How could I using the following example, change it to show 2 days ago within the same time frame 0600 AM to 0600 AM let foo=`date "+(1%H-106)*60+1%M-100"` bar=foo+1440 find . -mmin +$foo -mmin -$bar | tr -s '/','-' '^' | cut -f2,3 -d"^" | tr -s '^' ' ' | Please use code tags (7 Replies)
Discussion started by: freddie999
7 Replies

7. Shell Programming and Scripting

Calculating 7 days ago date for the given Argument

Hi I have shell script and I am facing the below issue to integrate the date calculation to the the script. If I give the $1 as the date(20110701) then I need to get the 7 days ago date for the same format.(20110624). At first I thought its a simple one to handle and I did a search in the... (10 Replies)
Discussion started by: filter
10 Replies

8. Shell Programming and Scripting

Find a string in file 5 days ago

Hi, I need to grep for a string "Color Yellow" in all log files dated 5 days back until today's date . So, as today is 20 Dec i need to find in all logs from 16th dec to 20 dec. Also, i need ls -ltre output for the files that have the "Collor Yellow" string. Below is my OS: ... (1 Reply)
Discussion started by: mohtashims
1 Replies

9. UNIX for Beginners Questions & Answers

How to find a file that's modified more than 2 days ago but less than 5 days ago?

How to find a file that's modified more than 2 days ago but was modified less than 5 days ago by use of any Linux utility ? (4 Replies)
Discussion started by: abdulbadii
4 Replies

10. Shell Programming and Scripting

Get a given date and subtract it to 5 days ago

Hi all, I have been researching to obtain SSL certification expiry for most of our webistes. For some cases, some hosts where not directly accessible so i finally got a solution working with curl using my proxy. This lists the expiry date which i'm finally looking for. # curl --proxy... (4 Replies)
Discussion started by: nms
4 Replies
Date::Format(3) 					User Contributed Perl Documentation					   Date::Format(3)

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, these are English, French, German and Italian. Changing the language is done via a static method call, for example Date::Format->language('German'); will change the language in which all subsequent dates are formatted. This is only a first pass, I am considering changing this to be $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 numeric day of the month, without leading zeros (eg 1..31) %D MM/DD/YY %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. AUTHOR
Graham Barr <gbarr@pobox.com> COPYRIGHT
Copyright (c) 1995-1999 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.8.0 2002-03-07 Date::Format(3)
All times are GMT -4. The time now is 04:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy