Sponsored Content
Top Forums Shell Programming and Scripting How to find all files for same month and year? Post 302898461 by Makarand Dodmis on Tuesday 22nd of April 2014 10:00:20 AM
Old 04-22-2014
How to find all files for same month and year?

Hi All,
I find all files for same month and year
lets say there are following files in directory

Code:
-rwxr-xr-x   1 user  userg         1596 Mar 19 2012 c.txt
-rwxr-xr-x   1 user  userg         1596 Mar 21 2012 d.txt
-rwxr-xr-x   1 user  userg         1596 Mar 22 2012 f.txt
-rwxr-xr-x   1 user  userg         1596 Mar 24 2012 h.txt
-rwxr-xr-x   1 user  userg         1596 Mar 25 2012 w.txt
-rwxr-xr-x   1 user  userg         1596 Feb 12 2012 q.txt
-rwxr-xr-x   1 user  userg         1596 Feb 21 2012 a.txt
-rwxr-xr-x   1 user  userg         1596 Feb 22 2012 s.txt
-rwxr-xr-x   1 user  userg         1596 Feb 23 2012 k.txt
-rwxr-xr-x   1 user  userg         1596 Feb 27 2012 j.txt
-rwxr-xr-x   1 user  userg         1596 Apr 12 2014 q.txt
-rwxr-xr-x   1 user  userg         1596 Apr 21 2014 a.txt
-rwxr-xr-x   1 user  userg         1596 Apr 22 2014 s.txt
-rwxr-xr-x   1 user  userg         1596 Apr 23 2014 k.txt
-rwxr-xr-x   1 user  userg         1596 Apr 27 2014 j.txt

output should be:
first set should be
Code:
-rwxr-xr-x   1 user  userg         1596 Mar 19 2012 c.txt
-rwxr-xr-x   1 user  userg         1596 Mar 21 2012 d.txt
-rwxr-xr-x   1 user  userg         1596 Mar 22 2012 f.txt
-rwxr-xr-x   1 user  userg         1596 Mar 24 2012 h.txt
-rwxr-xr-x   1 user  userg         1596 Mar 25 2012 w.txt

and second set should be
Code:
-rwxr-xr-x   1 user  userg         1596 Feb 12 2012 q.txt
-rwxr-xr-x   1 user  userg         1596 Feb 21 2012 a.txt
-rwxr-xr-x   1 user  userg         1596 Feb 22 2012 s.txt
-rwxr-xr-x   1 user  userg         1596 Feb 23 2012 k.txt
-rwxr-xr-x   1 user  userg         1596 Feb 27 2012 j.txt

third set should be
Code:
-rwxr-xr-x   1 user  userg         1596 Apr 12 2014 q.txt
-rwxr-xr-x   1 user  userg         1596 Apr 21 2014 a.txt
-rwxr-xr-x   1 user  userg         1596 Apr 22 2014 s.txt
-rwxr-xr-x   1 user  userg         1596 Apr 23 2014 k.txt
-rwxr-xr-x   1 user  userg         1596 Apr 27 2014 j.txt

 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
cal(1)								   User Commands							    cal(1)

NAME
cal - display a calendar SYNOPSIS
cal [ [month] year] DESCRIPTION
The cal utility writes a Gregorian calendar to standard output. If the year operand is specified, a calendar for that year is written. If no operands are specified, a calendar for the current month is written. OPERANDS
The following operands are supported: month Specify the month to be displayed, represented as a decimal integer from 1 (January) to 12 (December). The default is the current month. year Specify the year for which the calendar is displayed, represented as a decimal integer from 1 to 9999. The default is the current year. ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cal: LANG, LC_ALL, LC_CTYPE, LC_TIME, LC_MESSAGES, and NLSPATH. TZ Determine the timezone used to calculate the value of the current month. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
calendar(1), attributes(5), environ(5), standards(5) NOTES
An unusual calendar is printed for September 1752. That is the month 11 days were skipped to make up for lack of leap year adjustments. To see this calendar, type: cal 9 1752 The command cal 83 refers to the year 83, not 1983. The year is always considered to start in January. SunOS 5.10 1 Feb 1995 cal(1)
All times are GMT -4. The time now is 10:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy