Filter by Month


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filter by Month
# 1  
Old 05-06-2010
Filter by Month

Dear members,

I am on sun solaris 9.

I am looking for a KSH shell script that will find all log files created at least 3 month ago.

The idea is to scan 2 directories and get all log files created at least 3 month ago the present month and create by month and by type (RAP / ARCH ) a TAR file with all log files : exemple : download_12.2009.tar / archive_12.2009.tar ( 12 will mean december )

Exemple : We are on May, the script should look for all log files created beetween the 31 january and the max old file available.

here is the "ls - l" return value from the RAP directory :

Code:
-rw-------   1 master_val masterval    19893 Apr 16 12:43 download_file_SATURNE_R20100420.log

here is the "ls - l" return value from the ARCH directory :

Code:
-rw-------   1 master_val masterval    19893 Apr 16 12:43 archive_file_SATURNE_R20100420.log

Thanks for your help.

Last edited by Aswex; 05-06-2010 at 11:45 AM.. Reason: Forgot few things ; )
# 2  
Old 05-06-2010
you can achieve it using find command.. there is one option called -mtime in find command.
refer man page for more info and please give it a try :-)
# 3  
Old 05-06-2010
look into the find util. You can use this to build your selection array for tar, etc...

Code:
find $path_to_scan -type f -ctime +90 [-name "*REGEX_to_USE*" ]...

For example, I like this kind of thing:

Code:
tar cvpf - $(find $path_to_scan -type f -ctime +90 [-name "*REGEX_to_USE*" ]... ) |gzip -9 - >/archive_path/output.tgz

# 4  
Old 05-07-2010
Filter by Month

Dear posters,

thanks for your help. In other way I have to say that I am not as good as you are on shell script. I did try to search anwser on the web before to post my request by I did not managed to make it work.

I will try your help, but could you please, if you can tell me what mean :

Code:
*REGEX_to_USE

Thanks

---------- Post updated at 06:13 AM ---------- Previous update was at 02:13 AM ----------

Hello,

I have tried to use the command :

Code:
find $path_to_scan -type f -ctime +90

but is not working as I want. All files that could fit the need were not all detected.

I tried the -ctime and -mtime but this give me the same result anyway.

May I ask for a function if you already have one working for solaris ?

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

2. 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

3. 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

4. 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

5. 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

6. 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

7. Shell Programming and Scripting

Month Substitution

Team, How do i fetch details of the last day of the month i.e 31st,30th because we receive daily status report but not for the last days of the month.. because when i do an echo `date +%Y%m `${yesterday} it retrieves me 20100631 where as it should have been 20100531.. Hmm interesting!... (4 Replies)
Discussion started by: whizkidash
4 Replies

8. 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

9. Shell Programming and Scripting

Month name

Hi, Could you pls help me out in finding the name of next month.? For eg: date +"%b" gives the current month ie 'Jul' I want to get the output as 'Aug' Thanks, Jerry (4 Replies)
Discussion started by: jerrynimrod
4 Replies

10. Shell Programming and Scripting

How to match month

Dear all, i need script to ask to enter the month and if the enterd month is not valid prompt " Envalid entry try again " like this. eg - Enter the month : Jun script is proceeding if we enter incorrect month, Enter the month - Junn Invalid... (1 Reply)
Discussion started by: Nayanajith
1 Replies
Login or Register to Ask a Question