Process previous days file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Process previous days file
# 1  
Old 03-25-2013
Process previous days file

Hi,

i've a scenario where i need to unizp the previous day files based on the no of days given as input.

EX: if my no of days are 5 i need to go to archive dir and pull last 5 days files from currentday -1 .

Please help with this shell script.

Regards,
sandeep.
# 2  
Old 03-25-2013
You didn't mention what OS & SHELL you are using? Also can you show us what have you tried so far?
# 3  
Old 03-25-2013
Linux ,bash

The task is to get the archive files based on the no of days given as input which is a parameter and the format of the date is YYYYMMDD

so it looks like YYYYMMDD - $no of days...

20130325 - 5 days
i need to exract all the five days archive files from archive dir..

one option im trying yo use SQL..
# 4  
Old 03-25-2013
You can use find command with -newer option:

1. Touch a temporary file, specify time-stamp instead of current time:
Code:
touch -t 201303250000 /tmp/stamp$$

2. Use find to search files newer than temporary file created:
Code:
find . -maxdepth 1 -name "*.gz" -newer /tmp/stamp$$

# 5  
Old 03-25-2013
so if i use -maxdepth 5 then will i get the last 5 days of the current date??
# 6  
Old 03-25-2013
Quote:
Originally Posted by sandeep karna
so if i use -maxdepth 5 then will i get the last 5 days of the current date??
No, option -maxdepth levels is used to specify how many levels of directories you want to descend for searching files.

So -maxdepth 1 means the search is performed only on current directory.

You have to change the temporary file time-stamp accordingly to search the files as per your desired range.

Check find manual pages for further reference:
Code:
man find

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to find out process name that are running for last 10 days.

Hi all, As i am new to shell script.Please help me to write a Shell script to find out process name that are running for last 10 days. Thank's in advance. (8 Replies)
Discussion started by: manas_1988
8 Replies

2. Shell Programming and Scripting

Cancel process running for more than 5 days

Hello Group, We want to create a script in order to filter process in the system with more than five days (STIME) and then kill them under Solaris 10. How can we filter these kind of process ? ps -efa Thanks in advance for your help (4 Replies)
Discussion started by: csierra
4 Replies

3. Shell Programming and Scripting

Display previous days dates in ksh

---------- Post updated at 03:42 AM ---------- Previous update was at 03:38 AM ---------- Sorry for a duplicate post, my post at the first place could not appear due to some net issue on my machine. Here is what i posted earlier: Hi, i am using ksh in Solaris, i wanted to assign today's,... (5 Replies)
Discussion started by: pr5439
5 Replies

4. Shell Programming and Scripting

Can i get the previous/next days date of a selected day

Ok, the title is confusing i know, but it is a weird question. I have a bash script running on Centos5.8 and want to find a better way to do some date manipulation. What i am trying to do is get 3 days of files (day before, that day, and day after), concatenate the three files and pass them on... (2 Replies)
Discussion started by: oly_r
2 Replies

5. UNIX for Dummies Questions & Answers

Finding days in previous month

#!/bin/ksh day=1 month=1 year=2012 if then then prevmonth=31 elif then prevmonth=30 elif then then prevmonth=29 elif then prevmonth=29 else prevmonth=28 fi (4 Replies)
Discussion started by: vagar11
4 Replies

6. UNIX for Dummies Questions & Answers

How to count previous days files

Hi i know how to get no of files in some particular folder by following command which includes today and previous days files also ls |wc -l but i needed a command in which i can list previous one or two days files only. (4 Replies)
Discussion started by: rahiljavaid
4 Replies

7. UNIX for Dummies Questions & Answers

Append Previous Days date to filename

I need to append previous days date to my file which is generated using a script. I am working on Solaris 10. Thanks! (2 Replies)
Discussion started by: Twisha
2 Replies

8. Shell Programming and Scripting

Number of days in the previous month

Hi all. I am scripting in a POSIX shell on HPUX. I am running a script that needs to determine the number of days in a month. I found this on the forum and it works great: X=`cal $(date +%m) $(date +%Y) | grep -v '' | wc -w` The issue is that I am running the script on the 7th day of... (11 Replies)
Discussion started by: lyoncc
11 Replies

9. Shell Programming and Scripting

Script - How to automatically start another process when the previous process ends?

Hi all, I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this: 1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently. 2) So I loaded datafile A... (10 Replies)
Discussion started by: luna_soleil
10 Replies

10. UNIX for Dummies Questions & Answers

using 'date' to get previous days' dates

I am familiar with using the 'date' command to get the current date but I have a situation where I need to get the previous day's date as well as the date two days prior. Theoretically I could use 'expr' to compute these values but I need it to work in instances where the previous month's dates... (2 Replies)
Discussion started by: slant-40
2 Replies
Login or Register to Ask a Question