How to find all files for same month and year?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find all files for same month and year?
# 8  
Old 04-23-2014
Thanks Don for this useful post

1) The data i have provided is just a dummy data because i am not allowed to provide real data.i agree with your concerns

2) I just want set of files per month/year to iterate through.

3) i want to find files with first two dates & last date for that month/year

---------- Post updated at 03:38 AM ---------- Previous update was at 03:11 AM ----------

Hi Don
I am getting below error.Any help
Code:
./tunning.sh
./tunning.sh[6]: typeset: bad option(s)

my unix version
Code:
SunOS abc100 5.8 Generic_117350-61 sun4u sparc SUNW,Sun-Fire-V440

# 9  
Old 04-23-2014
Quote:
Originally Posted by Makarand Dodmis
Thanks Don for this useful post

1) The data i have provided is just a dummy data because i am not allowed to provide real data.i agree with your concerns

2) I just want set of files per month/year to iterate through.

3) i want to find files with first two dates & last date for that month/year

---------- Post updated at 03:38 AM ---------- Previous update was at 03:11 AM ----------

Hi Don
I am getting below error.Any help
Code:
./tunning.sh
./tunning.sh[6]: typeset: bad option(s)

my unix version
Code:
SunOS abc100 5.8 Generic_117350-61 sun4u sparc SUNW,Sun-Fire-V440

Dummy data is fine. You can change the files' owners to "user" (or if there are multiple users, "user1", "user2", ...) and the files' group names to "group" (or "group1", "group2", ...) and the files' names to "x1.txt", "x2.txt", ... "xn.txt", but changing output like:
Code:
-rw-r--r--   1 dwc  staff    8095 Apr 22 22:11 d.txt

to:
Code:
-rw-r--r--   1 dwc  staff    8095 Apr 22  2014 d.txt

hides information that is crucial to getting the results you want. You should easily be able to the save output from ls -lt in a file, edit the file to sanitize private data, and post the sanitized output without hiding data that your script is going to need to use to get the job done.

I explicitly said "the following Korn shell script (when using a 1993 or later version of ksh)". /bin/ksh on Solaris 8 is a 1988 version of the Korn shell. The 1988 version of the Korn shell doesn't have associative arrays. The awk script I provided should work fine for you if you change awk to /usr/xpg4/bin/awk or nawk. (I don't remember the path, but there might also be a 1993 version of ksh on Solaris 8 with a pathname something like /usr/dtbin/dtksh. You might be able to find it with:
ls /usr/*/dtksh /usr/*/*/dtksh

With the output that script provides you can easily grep for ":Oct 2013:" (or any other month and year you want) to find the files for that month and year. I assume you can pick the 1st two and the last one out of the matching grep output to get the files you want to process for that month. Of course it would also be pretty easy to just modify the awk script or a shell script to pass in the month and year you want and have it only print the names of the three (or all, if there are less than three) files that you want for that month.

Try to build on what we've given you here to get what you want. If it doesn't work, start another thread showing us what you have done, what (sanitized) input you're processing, and what output you;re hoping to get.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find all files other than last two dates per month and year?

Hi All, lets say there are following files in directory -rwxr-xr-x 1 user userg 1596 Mar 19 2012 a.txt -rwxr-xr-x 1 user userg 1596 Mar 19 2012 b.txt -rwxr-xr-x 1 user userg 1596 Mar 22 2012 c.txt -rwxr-xr-x 1 user userg 1596 Mar 24 2012 d.txt... (16 Replies)
Discussion started by: Makarand Dodmis
16 Replies

2. Shell Programming and Scripting

How to find all files other than first two dates & last date per month and year?

how to find all files other than first two dates & last date per month and year Hi All, lets say there are following files in directory -rwxr-xr-x 1 user userg 1596 Mar 19 2012 a.txt -rwxr-xr-x 1 user userg 1596 Mar 19 2012 b.txt -rwxr-xr-x 1 user userg ... (6 Replies)
Discussion started by: Makarand Dodmis
6 Replies

3. UNIX for Advanced & Expert Users

Find all files other than first two files dates & last file date for month

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (16 Replies)
Discussion started by: Makarand Dodmis
16 Replies

4. Shell Programming and Scripting

How to list files that are not first two files date & last file date for every month-year?

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies

5. UNIX for Dummies Questions & Answers

Unix man command to find out month of the year?

how can i display month of the year i was born with using man command? thanks (2 Replies)
Discussion started by: janetroop95
2 Replies

6. Shell Programming and Scripting

want to get last year and month from the file

Hi I have files like abc_cd_20110302_123423 abc_cd_ef_20110301_123423 abc_cd_ef_20110403_123423 abc_ef_20110401_123423 I want to extract the the year and month associated with each file. I tried logfileyearmonth=`echo $logfile | awk -F_'{print $NF}'` Any other way can I... (6 Replies)
Discussion started by: dgmm
6 Replies

7. Programming

Interval year to month

Hi, I'm working on a Informix4gl module. I'm just trying to find out any built-in function to fetch only the year/month from an INTERVAL YEAR TO MONTH data value. Please let me know, if there are any functions to do this. If not, let me know for any alternative solutions to attain this. ... (5 Replies)
Discussion started by: dvah
5 Replies

8. Shell Programming and Scripting

Concatenating Files In A Year/Month/Day File Structure

Hi Im trying to concatenate a specific file from each day in a year/month/day folder structure using Bash or equivalent. The file structure ends up like this: 2009/01/01/products 2009/01/02/products .... 2009/12/31/products The file I need is in products everyday and I need the script to... (3 Replies)
Discussion started by: Grizzly
3 Replies

9. UNIX for Advanced & Expert Users

how to get the last month and year in UNIX

how to get the last month and year in UNIx (2 Replies)
Discussion started by: Vijay06
2 Replies

10. UNIX for Advanced & Expert Users

find files with a perticular year of access

Hello all, Might be a silly question, on my AIX machine the year had changed to 2022 and some files were accessed on this date hence the time stamp on these files is with year 2022, there are many such files. i want to list all these file from the root dir and subdir with 2022 year... (3 Replies)
Discussion started by: pradeepmacha
3 Replies
Login or Register to Ask a Question