Sponsored Content
Full Discussion: Date wise calculations?
Top Forums Shell Programming and Scripting Date wise calculations? Post 302971114 by Don Cragun on Friday 15th of April 2016 06:42:21 PM
Old 04-15-2016
You might also want to try something like:
Code:
#!/bin/ksh
IAm=${0##*/}
if [ $# -ne 3 ]
then	printf 'Usage: %s year.month1 year.month2 filename\n' "$IAm" >&2
	exit 1
fi
awk -F'.' -v ym1="$1" -v ym2="$2" 'NR==1 || $1 FS $2==ym1 || $1 FS $2==ym2' "$3"

(I usually use the Korn shell, but you can use any shell that recognizes POSIX parameter expansions (e.g., ash, bash, dash, and many others in addition to ksh.)
If the sample data shown in post #1 in this thread is stored in a file named data and the above script is in an executable file named tester, then the command:
Code:
./tester 2015.09 2015.10 data

produces the output you requested and the command:
Code:
./tester 2015.09 2015.11 data

produces the output:
Code:
POST_DATE	CHECK_NUMBER	TYPE	LOGIN_NAME
2015.09.09	XXXXXXXXXX	mark XXXXXXXXXX
2015.09.09	XXXXXXXXXX	fsadf	XXXXXXXXXX
2015.09.14	XXXXXXXXXX	dt4e	XXXXXXXXXX
2015.11.18	XXXXXXXXXX	drew	XXXXXXXXXX

If you want to try this on a Solaris/SunOS system, change awk in the script to /usr/xpg4/bin/awk or nawk.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To extract data of a perticular interval (date-time wise)

I want a shell script which extract data from a log file which contains date and time-wise data and i need the data for a perticular interval of time...what can i do??? (3 Replies)
Discussion started by: abhishek27
3 Replies

2. UNIX for Dummies Questions & Answers

Date Calculations

I need to be able to use the current date and calculate 7 days ago to be stored in another variable to be passed to a file in my Unix shell script. I need the date in the following format: date '+%m/%d/%Y' or 05/16/2006 How do I calculate date minus 7 days or 1 week ago? (8 Replies)
Discussion started by: mitschcg
8 Replies

3. Shell Programming and Scripting

Need help with Date calculations in ksh

Hi Gurus, I am writing a script where we enter two dates, one a FROM DATE and the other a TO DATE. I need to validate that difference between the two dates is always less than or equal to 60 days. I could not find any date utility in ksh that could help me with this. Finally, I am deciding... (5 Replies)
Discussion started by: jidsh
5 Replies

4. Shell Programming and Scripting

Need to zip the files date wise --urgent Help needed

Hi all, this is my first post, i need to write a script to zip the files with datewise below are the log files. -rw------- 1 root sso 85316156 May 24 22:11 core_test_smservaz_104_104_1243217459_8896 -rw------- 1 root sso 90413304 May 25 22:12 core_test_smservaz_104_104_1243303895_20912... (4 Replies)
Discussion started by: lcschandu
4 Replies

5. Solaris

delete files by date wise

Hi guys, I want to delete files from june 13 to june 30, using rm command can any one tell me the sintax to remove. I ahve hunderd of core files in my /var dir. so i want to clear last month core files. Thanks in Advance.:)) (2 Replies)
Discussion started by: kurva
2 Replies

6. Shell Programming and Scripting

Date Calculations using script!!

Hi all, Thanks in Advance , i am very new to programming part in script i think using some caluations+ sed command only we can do this process in script. for exampl: i have file in that one line is like this using sed i can replace the date and all but my requirement is The... (3 Replies)
Discussion started by: anishkumarv
3 Replies

7. Shell Programming and Scripting

How to read files by Server Creation date wise?

Hi All, I would have many files in the server with xyz*.dat -- Static file name Physical files: xyz1.dat - 01PM xyz2.dat - 02PM xyz3.dat - 03PM In present version we are using for f in $file_name do fname=`ls $f | grep -v ^'\|'$ | sed s/' '/'\\ '/g` .... sqlldr... (4 Replies)
Discussion started by: Dharv
4 Replies

8. Shell Programming and Scripting

Generate sum of a particular column date wise

Hi All, I have a file with below content 01/22/2014,23:43:00,1742.8, 01/22/2014,23:43:00,1742.8, 01/22/2014,23:44:00,1749.06666666667, 01/25/2014,23:45:00,2046.45, 01/25/2014,23:43:00,1742.8, 01/25/2014,23:44:00,1749.06666666667, 01/25/2014,23:45:00,2046.45, 01/25/2014,23:43:00,1742.8,... (4 Replies)
Discussion started by: villain41
4 Replies

9. Shell Programming and Scripting

Extract count of string in all files and display on date wise

Hi All, hope you all are doing well! I kindly ask you for shell scripting help, here is the description: I have huge number of files shown below on date wise, which contains different strings(numbers you can say) including 505001 and 602001. ... (14 Replies)
Discussion started by: VasuKukkapalli
14 Replies

10. Shell Programming and Scripting

Insert values into a file 0 as per the date wise

Hi The file contains 12 months of date and less than 12 months of data I want to display if date filed less than 12 months of data I want to insert a value amount 1 to amount4 0 and dates as well. 12345|Date|cntry|amount1|amount2|amount3|amoun4... (2 Replies)
Discussion started by: jagu
2 Replies
DateTime::Locale::or(3) 				User Contributed Perl Documentation				   DateTime::Locale::or(3)

NAME
DateTime::Locale::or SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'or' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Oriya. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) XXXXXX XXXXXXXX XXXXXX XXXXXXX XXXXXXXX XXXXXX XXXXXX Abbreviated (format) XXX XXXXX XXX XXXX XXXXX XXX XXX Narrow (format) XX X XX XX XX X X Wide (stand-alone) XXXXXX XXXXXXXX XXXXXX XXXXXXX XXXXXXXX XXXXXX XXXXXX Abbreviated (stand-alone) XXX XXXXX XXX XXXX XXXXX XXX XXX Narrow (stand-alone) XX X XX XX XX X X Months Wide (format) XXXXXXX XXXXXXXXXX XXXXXXX XXXXXX XX XXX XXXXX XXXXX XXXXXXXXXX XXXXXXX XXXXXXX XXXXXXXX Abbreviated (format) XXXXXXX XXXXXXXXXX XXXXXXX XXXXXX XX XXX XXXXX XXXXX XXXXXXXXXX XXXXXXX XXXXXXX XXXXXXXX Narrow (format) XX XX XX X XX XX XX X XX X X XX Wide (stand-alone) XXXXXXX XXXXXXXXXX XXXXXXX XXXXXX XX XXX XXXXX XXXXX XXXXXXXXXX XXXXXXX XXXXXXX XXXXXXXX Abbreviated (stand-alone) 1 2 3 4 5 6 7 8 9 10 11 12 Narrow (stand-alone) XX XX XX X XX XX XX X XX X X XX Quarters Wide (format) Q1 Q2 Q3 Q4 Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) Q1 Q2 Q3 Q4 Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide BCE CE Abbreviated BCE CE Narrow BCE CE Date Formats Full 2008-02-05T18:30:30 = XXXXXXXX, 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = XXXXXXXX, 22 XXXXXXXX 1995 -0010-09-15T04:44:23 = XXXXXX, 15 XXXXXXXXXX -10 Long 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXXXXXXX -10 Medium 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXXXXXXX -10 Short 2008-02-05T18:30:30 = 5-2-08 1995-12-22T09:05:02 = 22-12-95 -0010-09-15T04:44:23 = 15-9--10 Default 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXXXXXXX -10 Time Formats Full 2008-02-05T18:30:30 = 6:30:30 pm UTC 1995-12-22T09:05:02 = 9:05:02 am UTC -0010-09-15T04:44:23 = 4:44:23 am UTC Long 2008-02-05T18:30:30 = 6:30:30 pm UTC 1995-12-22T09:05:02 = 9:05:02 am UTC -0010-09-15T04:44:23 = 4:44:23 am UTC Medium 2008-02-05T18:30:30 = 6:30:30 pm 1995-12-22T09:05:02 = 9:05:02 am -0010-09-15T04:44:23 = 4:44:23 am Short 2008-02-05T18:30:30 = 6:30 pm 1995-12-22T09:05:02 = 9:05 am -0010-09-15T04:44:23 = 4:44 am Default 2008-02-05T18:30:30 = 6:30:30 pm 1995-12-22T09:05:02 = 9:05:02 am -0010-09-15T04:44:23 = 4:44:23 am Datetime Formats Full 2008-02-05T18:30:30 = XXXXXXXX, 5 XXXXXXXXXX 2008 6:30:30 pm UTC 1995-12-22T09:05:02 = XXXXXXXX, 22 XXXXXXXX 1995 9:05:02 am UTC -0010-09-15T04:44:23 = XXXXXX, 15 XXXXXXXXXX -10 4:44:23 am UTC Long 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 6:30:30 pm UTC 1995-12-22T09:05:02 = 22 XXXXXXXX 1995 9:05:02 am UTC -0010-09-15T04:44:23 = 15 XXXXXXXXXX -10 4:44:23 am UTC Medium 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 6:30:30 pm 1995-12-22T09:05:02 = 22 XXXXXXXX 1995 9:05:02 am -0010-09-15T04:44:23 = 15 XXXXXXXXXX -10 4:44:23 am Short 2008-02-05T18:30:30 = 5-2-08 6:30 pm 1995-12-22T09:05:02 = 22-12-95 9:05 am -0010-09-15T04:44:23 = 15-9--10 4:44 am Default 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 6:30:30 pm 1995-12-22T09:05:02 = 22 XXXXXXXX 1995 9:05:02 am -0010-09-15T04:44:23 = 15 XXXXXXXXXX -10 4:44:23 am Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 XXXXX 1995-12-22T09:05:02 = 22 XXXXX -0010-09-15T04:44:23 = 15 XXX Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 pm 1995-12-22T09:05:02 = 9:05 am -0010-09-15T04:44:23 = 4:44 am Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 pm 1995-12-22T09:05:02 = 9:05:02 am -0010-09-15T04:44:23 = 4:44:23 am M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = XXXXX, 2-5 1995-12-22T09:05:02 = XXXXX, 12-22 -0010-09-15T04:44:23 = XXX, 9-15 MMdd (dd-MM) 2008-02-05T18:30:30 = 05-02 1995-12-22T09:05:02 = 22-12 -0010-09-15T04:44:23 = 15-09 MMM (LLL) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 MMMd (MMM d) 2008-02-05T18:30:30 = XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXXXXX 22 -0010-09-15T04:44:23 = XXXXXXXXXX 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = XXXXX XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXX XXXXXXXX 22 -0010-09-15T04:44:23 = XXX XXXXXXXXXX 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXXXXX 22 -0010-09-15T04:44:23 = XXXXXXXXXX 15 MMMMEd (E MMMM d) 2008-02-05T18:30:30 = XXXXX XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXX XXXXXXXX 22 -0010-09-15T04:44:23 = XXX XXXXXXXXXX 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = XXXXX, 2008-2-5 1995-12-22T09:05:02 = XXXXX, 1995-12-22 -0010-09-15T04:44:23 = XXX, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 XXXXXXXXXX 1995-12-22T09:05:02 = 1995 XXXXXXXX -0010-09-15T04:44:23 = -10 XXXXXXXXXX yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = XXXXX, 2008 XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXX, 1995 XXXXXXXX 22 -0010-09-15T04:44:23 = XXX, -10 XXXXXXXXXX 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 XXXXXXXXXX 1995-12-22T09:05:02 = 1995 XXXXXXXX -0010-09-15T04:44:23 = -10 XXXXXXXXXX yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 Q1 1995-12-22T09:05:02 = 1995 Q4 -0010-09-15T04:44:23 = -10 Q3 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 yyyyMM (MM-yyyy) 2008-02-05T18:30:30 = 02-2008 1995-12-22T09:05:02 = 12-1995 -0010-09-15T04:44:23 = 09--010 yyyyMMMM (MMMM y) 2008-02-05T18:30:30 = XXXXXXXXXX 2008 1995-12-22T09:05:02 = XXXXXXXX 1995 -0010-09-15T04:44:23 = XXXXXXXXXX -10 Miscellaneous Prefers 24 hour time? No Local first day of the week XXXXXX SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.18.2 2017-10-06 DateTime::Locale::or(3)
All times are GMT -4. The time now is 10:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy