Sponsored Content
Full Discussion: Getting month older
Top Forums Shell Programming and Scripting Getting month older Post 302846071 by rdcwayx on Friday 23rd of August 2013 02:10:57 AM
Old 08-23-2013
Need GNU date command:

Code:
#! /bin/bash
d=$(date -d "-30 days" +%Y%m%d%H%M%S)

awk -v d=$d '{split($3,a,"-");split($4,b,":")
    s=sprintf("%04d%02d%02d%02d%02d%02d",a[1],a[2],a[3],b[1],b[2],b[3])
    if (s<d) { print $2> "outputfile1"}
    else {print > "outputfile2"}
    }' file
echo mv outputfile2 file

if command is right, remove the red echo
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

rm files older than ...

Hello, How can I remove files older than yesterday or the day before or a given day ... Thank you in advance (2 Replies)
Discussion started by: annemar
2 Replies

2. Shell Programming and Scripting

Zipping files older than one month

I have to zip all files older than a month within a directory. I have to archive them using the file extension I have .dat, .csv ,.cnt files within the directory. I used the following command It doesnt work find /path/*.dat -mtime +30 This command doesnot display .dat files older than a... (2 Replies)
Discussion started by: ramky79
2 Replies

3. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

4. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

5. Shell Programming and Scripting

find file older than one month not by x days olds

Hi, I would like to ask about some question on the -mtime option in the find command. I want to move a log files older than one month and planning to used the find -mtime +30 but i have some clarrification does -mtime +30 or -30 refer to x days beyond or between so how about the month. suppose... (2 Replies)
Discussion started by: jao_madn
2 Replies

6. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

7. Shell Programming and Scripting

Convert From Month Number to Month Name

Hi, I have a script that accepts an input date from the user in yyyy-mm-dd format. I need to get the mm-dd part and convert it to month name. example: 2011-11-15 I want that to become "Nov 15" I don't have the GNU date, I am using an AIX os. Thanks. (1 Reply)
Discussion started by: erin00
1 Replies

8. Shell Programming and Scripting

How to add decimal month to some month in sql, php, perl, bash, sh?

Hello, i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m i need to write this script in php or bash or sh or mysql or perl in normal time o unix time i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Discussion started by: bacarrdy
14 Replies

9. Shell Programming and Scripting

Need last month files after 10th of every month

Hi, I need all file names in a folder which has date >= 10th of last month, Example : files in folder AUTO_F1_20140610.TXT BUTO_F1_20140616.TXT CUTO_F1_20140603.TXT FA_AUTO_06012014.TXT LA_AUTO_06112014.TXT MA_AUTO_06212014.TXT ZA_AUTO_06232014.TXT Output: AUTO_F1_20140610.TXT... (9 Replies)
Discussion started by: nani1984
9 Replies

10. UNIX for Beginners Questions & Answers

Hadoop directories delete older than a month

-bash-4.1$ hdfs dfs -ls -R /data/backup/prd/xyz/ | grep '^d' drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180301 drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180302 drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03... (2 Replies)
Discussion started by: himanshupant
2 Replies
DateTime::Format::Natural(3pm)				User Contributed Perl Documentation			    DateTime::Format::Natural(3pm)

NAME
DateTime::Format::Natural - Create machine readable date/time with natural parsing logic SYNOPSIS
use DateTime::Format::Natural; $parser = DateTime::Format::Natural->new; $date_string = $parser->extract_datetime($extract_string); @date_strings = $parser->extract_datetime($extract_string); $dt = $parser->parse_datetime($date_string); @dt = $parser->parse_datetime_duration($date_string); if ($parser->success) { # operate on $dt/@dt, for example: printf("%02d.%02d.%4d %02d:%02d:%02d ", $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec); } else { warn $parser->error; } @traces = $parser->trace; DESCRIPTION
"DateTime::Format::Natural" takes a string with a human readable date/time and creates a machine readable one by applying natural parsing logic. CONSTRUCTOR
new Creates a new "DateTime::Format::Natural" object. Arguments to "new()" are options and not necessarily required. $parser = DateTime::Format::Natural->new( datetime => DateTime->new(...), lang => 'en', format => 'mm/dd/yy', prefer_future => '[0|1]', time_zone => 'floating', daytime => { morning => 06, afternoon => 13, evening => 20, }, ); o "datetime" Overrides the present now with a DateTime object provided. o "lang" Contains the language selected, currently limited to "en" (english). Defaults to '"en"'. o "format" Specifies the format of numeric dates, defaults to '"d/m/y"'. o "prefer_future" Turns ambiguous weekdays/months to their future relatives. Accepts a boolean, defaults to false. o "time_zone" The time zone to use when parsing and for output. Accepts any time zone recognized by DateTime. Defaults to 'floating'. o "daytime" An anonymous hash reference consisting of customized daytime hours, which may be selectively changed. METHODS
parse_datetime Returns a DateTime object constructed from a human readable date/time string. $dt = $parser->parse_datetime($date_string); $dt = $parser->parse_datetime(string => $date_string); o "string" The date string. parse_datetime_duration Returns one or two DateTime objects constructed from a human readable date/time string which may contain timespans/durations. Same interface and options as "parse_datetime()", but should be explicitly called in list context. @dt = $parser->parse_datetime_duration($date_string); @dt = $parser->parse_datetime_duration(string => $date_string); extract_datetime Returns parsable date/time substrings (also known as expressions) extracted from the string provided; in scalar context only the first parsable substring is returned, whereas in list context all parsable substrings are returned. Each extracted substring can then be passed to the "parse_datetime()"/ "parse_datetime_duration()" methods. $date_string = $parser->extract_datetime($extract_string); @date_strings = $parser->extract_datetime($extract_string); # or $date_string = $parser->extract_datetime(string => $extract_string); @date_strings = $parser->extract_datetime(string => $extract_string); success Returns a boolean indicating success or failure for parsing the date/time string given. error Returns the error message if the parsing did not succeed. trace Returns one or two strings with the grammar keyword for the valid expression parsed, traces of methods which were called within the Calc class and a summary how often certain units have been modified. More than one string is commonly returned for durations. Useful as a debugging aid. GRAMMAR
The grammar handling has been rewritten to be easily extendable and hence everybody is encouraged to propose sensible new additions and/or changes. See the classes "DateTime::Format::Natural::Lang::[language_code]" if you're intending to hack a bit on the grammar guts. EXAMPLES
See the classes "DateTime::Format::Natural::Lang::[language_code]" for an overview of currently valid input. BUGS &; CAVEATS "parse_datetime()"/"parse_datetime_duration()" always return one or two DateTime objects regardless whether the parse was successful or not. In case no valid expression was found or a failure occurred, an unaltered DateTime object with its initial values (most often the "current" now) is likely to be returned. It is therefore recommended to use "success()" to assert that the parse did succeed (at least, for common uses), otherwise the absence of a parse failure cannot be guaranteed. "parse_datetime()" is not capable of handling durations. CREDITS
Thanks to Tatsuhiko Miyagawa for the initial inspiration. See Miyagawa's journal entry <http://use.perl.org/~miyagawa/journal/31378> for more information. Furthermore, thanks to (in order of appearance) who have contributed valuable suggestions and patches: Clayton L. Scott Dave Rolsky CPAN Author 'SEKIMURA' mike (pulsation) Mark Stosberg Tuomas Jormola Cory Watson Urs Stotz Shawn M. Moore Andreas J. Koenig Chia-liang Kao Jonny Schulz Jesse Vincent Jason May Pat Kale Ankur Gupta Alex Bowley Elliot Shank Anirvan Chatterjee Michael Reddick Christian Brink Giovanni Pensa Andrew Sterling Hanenkamp Eric Wilhelm Kevin Field Wes Morgan Vladimir Marek Rod Taylor Tim Esselens Colm Dougan Chifung Fan Xiao Yafeng Roman Filippov SEE ALSO
dateparse, DateTime, Date::Calc, <http://datetime.perl.org> AUTHOR
Steven Schubiger <schubiger@cpan.org> LICENSE
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. See <http://dev.perl.org/licenses/> perl v5.14.2 2012-05-31 DateTime::Format::Natural(3pm)
All times are GMT -4. The time now is 11:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy