Sponsored Content
Top Forums Shell Programming and Scripting UNIX: Search file between two Date stamps Post 302761055 by santhosh86467 on Friday 25th of January 2013 04:28:33 AM
Old 01-25-2013
Thank you so much bipinajith and Chubler_XL . I used the unix find command now and it looks fine.. here is my code
Code:
findFile () {
   INPUTDATE=$1

 
 
   YY=`echo $INPUTDATE | cut -f 1 -d "/" | cut -f 1 -d " "`
   MM=`echo $INPUTDATE | cut -f 2 -d "/" | cut -f 1 -d " "`
   DD=`echo $INPUTDATE | cut -f 3 -d "/" | cut -f 1 -d " "`
   echo "INPUT FILE ${YY}${MM}${DD}0000"
   touch -t ${YY}${MM}${DD}0000 ${DB_DUMPS_DIR}/DBREFRESHDATE
   if [[ $DD -lt 8 ]]
   then
      if [[ $MM -eq 1 ]]
      then
         (( MM -= 1 ))
         (( MM += 12 ))
         (( YY -= 1 ))
      else
         (( MM -= 1 ))
         if [[ $MM -lt 10 ]]
         then
            MM=0$MM
         fi
      fi
      (( DD -= 7 ))
      (( DD += 30 ))
   else
      (( DD -= 7 ))
      if [[ $DD -lt 10 ]]
      then
         DD=0$DD
      fi
   fi

   echo  "NEW FILE ${YY}${MM}${DD}0000"
   touch -t ${YY}${MM}${DD}0000 ${DB_DUMPS_DIR}/DBDUMPDATE
   cd ${DB_DUMPS_DIR}
   find . -newer DBDUMPDATE ! -newer DBREFRESHDATE | egrep -v DBREFRESHDATE
   if [[ $? -eq 0 ]]
   then
      echo "Found data"
      FOUND=1
   else
      echo "Could not find data"
      NEWDATE=${YY}/${MM}/${DD}
      FOUND=0
   fi
}


Last edited by Franklin52; 01-25-2013 at 05:42 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

find file with date and recursive search for a text

Hey Guyz I have a requirement something like this.. a part of file name, date of modification of that file and a text is entered as input. like Date : 080206 (MMDDYY format.) filename : hotel_rates text : Jim now the file hotel_rates.ZZZ.123 (creation date is Aug 02 2006) should be... (10 Replies)
Discussion started by: rosh0623
10 Replies

2. UNIX for Dummies Questions & Answers

Changing Creation Date to a Prespecified Date of a File In Unix

Dear Expert, Is there a command to do that in Unix? In such a way that we don't need to actually "write" or modified the content. -- monkfan (4 Replies)
Discussion started by: monkfan
4 Replies

3. UNIX for Dummies Questions & Answers

List files with date and time stamps only

Hi there, I'm using terminal on mac and using the ls -l command to list all the files in a directory. However, I only want to display the date and time stamp of each file rather than permissions, owner, group etc... Is this possible? Many thanks in advance Dave (2 Replies)
Discussion started by: davewg
2 Replies

4. UNIX for Dummies Questions & Answers

Adding Date & time stamps to filename

I need to edit the file name with date and time while writing the script. please help. (1 Reply)
Discussion started by: manish.s
1 Replies

5. UNIX for Dummies Questions & Answers

Search for a file with Current Date

Hi, How can we search for a file with current date(sysdate). Actually i want the file name from a directory which was created today(current date). For example i have a dir /home/arch and i have files with name aglito03axyz.datetimestamp in this directory, but all these files were created... (7 Replies)
Discussion started by: sandeep_1105
7 Replies

6. Shell Programming and Scripting

Perl - Search file between two time stamps

Hi, I am on a windows system that receives files from differnet host, I have to find the count of files that we receive between specific time. The code below is what i use to count the number of file, how do i change this to count files between specfic time opendir ( DIR, $dir ) || die... (1 Reply)
Discussion started by: amit1_x
1 Replies

7. Shell Programming and Scripting

How to search for file and display by date

I like "ls -ltr". I would like to search for a file in a large directory recursively and and display all the candidates in reverse order. /usr/bin/find . -name \*.txt This works. How do I display the date and sort the file names by the date in reverse order for the entire directory... (1 Reply)
Discussion started by: siegfried
1 Replies

8. Shell Programming and Scripting

How to search log file from a date

Hi All, I want to grep through all the log files created from 20th August. How do I do that? My script will run everyday. So it will take current date as To_Date. My log file name looks like - applog-2012-08-20-000001....applog-2012-08-20-000002...etc. Thanks in advance. (5 Replies)
Discussion started by: kmajumder
5 Replies

9. Shell Programming and Scripting

date time stamps in bash

I'm looking for a way to have the "date" command output the date in a specific format. I'm not familiar with the different ways to use the date command at all. i read up on it, but i dont get how to manipulate it. i know that i can get the date format to give me a format like: 2012-10-13... (6 Replies)
Discussion started by: SkySmart
6 Replies

10. Shell Programming and Scripting

How to search file for a date variable?

Hello, I'm trying to write a ksh script which will allow me to to search for yesterday's date within a rtf file. I just need someway to know if the date is in the file, echo results to a text file, and then mail that out. The format of the date is mm/dd/yyyy. I had to make a variable... (2 Replies)
Discussion started by: ronan1219
2 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy