Sponsored Content
Full Discussion: Date Range in UNIX
Top Forums Shell Programming and Scripting Date Range in UNIX Post 302761141 by fpmurphy on Friday 25th of January 2013 07:05:46 AM
Old 01-25-2013
Using the ksh93 shell ...
Code:
#!/bin/ksh93

nextdate=$(printf "%(%s)T" "$1")
enddate=$(printf "%(%s)T" "$2")
typeset -i DAY=24*60*60

while (( nextdate < enddate ))
do
    printf "%(%Y-%m-%d)T" "#${nextdate}"
    for ((i=1; i < 7 &&  0 == $(( (nextdate + $DAY) > enddate )); i++))
    do
       (( nextdate += $DAY ))
    done
    printf "   %(%Y-%m-%d)T\n" "#${nextdate}"
done

produces
Code:
$ ./run.sh  2012-01-01 2012-01-30
2012-01-01   2012-01-07
2012-01-07   2012-01-13
2012-01-13   2012-01-19
2012-01-19   2012-01-25
2012-01-25   2012-01-30
$

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cp only files in certain date range

hi all, I'm trying to do a cp only on files I created on a given day or within a certain date range. What's the best way to do this? Cheers, KL (1 Reply)
Discussion started by: ee7klt
1 Replies

2. Shell Programming and Scripting

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

3. Programming

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

4. UNIX for Advanced & Expert Users

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

5. Shell Programming and Scripting

Get date range between 2 date input

Hi Experts, I have files name report_20090416 report_20090417 report_20090418 report_20090420 report_20090421 I have 2 input from user From Date: 20090417 To Date: 20090420 and I need to grep only those line in between. Output should be report_20090417 report_20090418... (3 Replies)
Discussion started by: tanit
3 Replies

6. UNIX Desktop Questions & Answers

date range

I have a number of instances wher I need to run reports for the previous month and need to include the last months date range in the sql. I want to create a string which consists of the first and last dates of last month separated with an ' and ' ie for this month (Feb) I want it to say '01/01/10... (3 Replies)
Discussion started by: Niven
3 Replies

7. Shell Programming and Scripting

Date Range Problem

Hi All, I have a log file which has first few characters of every line as a timestamp. 2010-06-01 04:56:02,802 DEBUG {Thread-27} Some text message 2010-06-01 04:56:02,802 DEBUG {Thread-27} Some text message 2010-06-01 04:56:02,802 DEBUG {Thread-27} Some text message 2010-06-01... (7 Replies)
Discussion started by: nitin14341
7 Replies

8. Shell Programming and Scripting

Date listing in a date range

Solaris 10 ksh88 Sorry for re-hashing some of this, but I can't find a proper solution in the forums. Starting with /a/archive containing (on and on date formatted directories) 20060313 20080518 20100725 20121015 20060314 20080519 ... (1 Reply)
Discussion started by: moesplace
1 Replies

9. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies

10. Shell Programming and Scripting

Date range

Dear all, how can I select in the file below only the files created between Aug 14 2014 and Feb 03 2015? EZA2284I -rw-r--r-- 1 30 8 356954 Aug 15 2014 file1 EZA2284I -rw-rw-r-- 1 30 8 251396 Feb 05 12:53 file2 EZA2284I -rw-rw-r-- 1 30 8 ... (3 Replies)
Discussion started by: simomuc
3 Replies
XPRINTF_EXEC(3) 					   BSD Library Functions Manual 					   XPRINTF_EXEC(3)

NAME
asxprintf_exec, dxprintf_exec, fxprintf_exec, sxprintf_exec, xprintf_exec, vasxprintf_exec, vdxprintf_exec, vfxprintf_exec, vsxprintf_exec, vxprintf_exec -- execute-only extensible printf execution SYNOPSIS
#include <printf.h> int asxprintf_exec(char ** restrict ret, printf_comp_t restrict pc, ...); int dxprintf_exec(int fd, printf_comp_t restrict pc, ...); int fxprintf_exec(FILE * restrict stream, printf_comp_t restrict pc, ...); int sxprintf_exec(char * restrict str, size_t size, printf_comp_t restrict pc, ...); int xprintf_exec(printf_comp_t restrict pc, ...); #include <stdarg.h> int vasxprintf_exec(char ** restrict ret, printf_comp_t restrict pc, va_list ap); int vdxprintf_exec(int fd, printf_comp_t restrict pc, va_list ap); int vfxprintf_exec(FILE * restrict stream, printf_comp_t restrict pc, va_list ap); int vsxprintf_exec(char * restrict str, size_t size, printf_comp_t restrict pc, va_list ap); int vxprintf_exec(printf_comp_t restrict pc, va_list ap); DESCRIPTION
These functions are execute-only, extensible printf (see xprintf(5)) variants, taking a printf_comp_t structure created by the format string compilation routine new_printf_comp(3). All these variants behave like their normal printf counterparts (see printf(3)) without 'x' and ``_exec'' in the name (except sxprintf_exec() and vsxprintf_exec() behave like snprintf() and vsnprintf(), respectively). SEE ALSO
printf(3), xprintf_comp(3), xprintf(5) Darwin Aug 19, 2012 Darwin
All times are GMT -4. The time now is 07:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy