Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Subtract -1 from a date in Unix script Post 302370985 by thegeek on Friday 13th of November 2009 04:38:19 AM
Old 11-13-2009
if that is a PERL script, you can use Date::Manip, or Date::Calc .


if you want that to be done from a current date, then you can do it simply with GNU date command, as

Code:
$ date --date='1 day ago'
Thu Nov 12 15:07:46 IST 2009
$ date
Fri Nov 13 15:07:53 IST 2009

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to subtract 2 hours from 'date' in shell ( /bin/sh ) script ?

I write a sh script that zip and copy to tape all files that older then 2 hours. 1. The way I choose is - touch a file with "now - 2 hours", then use fine with '! -newer' 2. Do you have any other idea to do it ? tnx. (1 Reply)
Discussion started by: yairon
1 Replies

2. Shell Programming and Scripting

Subtract two date in unix

I Have a long file like this 123122312 05/06/12 123123456 05/06/14 I want to take the difference of dates in two lines & print difference sidewise for the whole long files. Pl help me out. (1 Reply)
Discussion started by: vanand
1 Replies

3. UNIX for Advanced & Expert Users

Subtract 2 months from the date

I have the script which appends month and year to the name of the file. Now every time when I append the month-year combination I have to subtract 2 months from the current date and then append it, since we are sending our vendor 2 months prior worth of data eveytime. #! /usr/bin/ksh ... (5 Replies)
Discussion started by: mahekr2000
5 Replies

4. Shell Programming and Scripting

Date command - subtract from given time

the given time is: 12:13:00 how do i subtract a 10 minutes from any given time? date '12:13:00' '-10 min' also tried this: date +12:13:00 '-10 min' (2 Replies)
Discussion started by: SkySmart
2 Replies

5. Shell Programming and Scripting

Subtract date in a loop

I have a file with name and date--- $ cat file.log userA 01-06-2014 userB 25-05-2014 userC 16-05-2014 userC 01-03-2014 I want to search for the current date and get the name for that date. If current date is not found, go back 1 day and search and so on till it finds the... (2 Replies)
Discussion started by: Nagesh_1985
2 Replies

6. UNIX for Dummies Questions & Answers

Subtract minutes from date

Hi, I am reading a particular date from a file using below command WFLWDATE=$(sed '2q;d' FileA.prm) The echo command outputs the correct date in variable WFLWDATE Now I want to subtract 5 minutes from this variable. I am on AIX and unable to get anything working as expected. Can you... (1 Reply)
Discussion started by: vrupatel
1 Replies

7. Shell Programming and Scripting

Subtract months/days from date

Hi, Can you please let me know code for the below (in korn shell) a) Subtract month(s) from given date b) Subtract day(s) from give date c) Subtract month(s) from given timestamp d) Subtract day(s) from give timestamp (1 Reply)
Discussion started by: tostay2003
1 Replies

8. Shell Programming and Scripting

Subtract a file's modification date with current date

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise Hi, In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file. How do I achieve this? Regards, Joe (2 Replies)
Discussion started by: roshanbi
2 Replies

9. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies
CGI::Untaint::date(3pm) 				User Contributed Perl Documentation				   CGI::Untaint::date(3pm)

NAME
CGI::Untaint::date - validate a date SYNOPSIS
use CGI::Untaint; my $handler = CGI::Untaint->new($q->Vars); my $date = $handler->extract(-as_date => 'date'); DESCRIPTION
is_valid This Input Handler verifies that it is dealing with a reasonable date. Reasonably means anything that Date::Manip thinks is sensible, so you could use any of (for example): "December 12, 2001" "12th December, 2001" "2001-12-12" "next Tuesday" "third Wednesday in March" See Date::Manip for much more information on what date formats are acceptable. The resulting date will be a Date::Simple object. Date::Simple for more information on this. date_format By default ambiguous dates of the format 08/09/2001 will be treated as UK style (i.e. 8th September rather than 9th August) If you want to change this, subclass it and override date_format() WARNING
Date::Manip does not play nicely with taint mode. In order to work around this we locally clobber Date::Manip's 'timezone' code. As we're only interested in dates rather than times, this shouldn't be much of an issue. If it is, then please let me know! SEE ALSO
Date::Simple. Date::Manip. AUTHOR
Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-CGI-Untaint-date@rt.cpan.org COPYRIGHT and LICENSE Copyright (C) 2001-2005 Tony Bowden. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2008-05-12 CGI::Untaint::date(3pm)
All times are GMT -4. The time now is 05:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy