You could use ls -rlt to have ls order the listing by date/time.
How do you want the month sets separated? Blank line between each; output to filename with month in it; or something else?
It might be easier to get the tools to do the work for you rather than to search and manipulate the output yourself. Using the touch command, you can create files with specific timestamps:-
You should be able to build a for loop around this to set the start and end dates.
I hope that this helps,
Robin
Liverpool/Blackburn
UK
There are some very strange things going on in this thread:
Makarand Dodmis tells us that he has the following files in a directory:
Note that there are several pairs of files with the same names, but different dates. Obviously this can' t happen in a single directory!
Standard ls -lt or ls -ltr output would sort the dates from oldest to newest or newest to oldest; not in the order shown above with the oldest files in the middle of the listings.
And, files with dates in the past six months would be shown with a timestamp rather than a year in the date display. (This means that some files from October 2013 will be displayed with a timestamp and some will be presented with a year if ls -l is run in April 2014.
And, finally, ls -l with or without other options will also print a line something like:
at the start of the output.
Chubler_XL's script ignores the year and assumes that grouping by month will be sufficient to get what is desired. (And, it works for the sample data given. Although it also prints the "total" line.)
vgersh99's script gets a syntax error on the "total" line and treats each timestamp on files in the previous six months as a different year.
In a directory where ls -lrt (when run on April 22, 2014 after 8pm) produces the output:
the awk script:
(change awk to /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk on Solaris/SunOS systems) and the following Korn shell script (when using a 1993 or later version of ksh):
both produce the output:
This User Gave Thanks to Don Cragun For This Post:
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)
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)
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)
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)
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)
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)
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)
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)