Sponsored Content
Top Forums UNIX for Advanced & Expert Users Find all files other than first two files dates & last file date for month Post 302897468 by vbe on Monday 14th of April 2014 09:35:48 AM
Old 04-14-2014
My way of seeing things is you know what you dont want : search for them first and create a list with them, then parse the directory excluding the list content

Code:
MONTH=Sep
-rwxr-xr-x    1 vbe      bin             110 Sep  3 2003  tutu.sav
-rwxr-x---    1 vbe      bin              17 Sep  4 2003  tata
-rw-rw-r--    1 vbe      system         7696 Sep 30 2013  bdf_today.130930
n12:/home/vbe $ ll -lrt|grep " Sep "|grep -v -f test.0009|more                                  
-rw-rw-rw-    1 vbe      bin              21 Sep  9 2003  testread.out
-rw-rw-rw-    1 vbe      bin            1940 Sep  9 2003  cutresults
-rwxrw-rw-    1 vbe      bin             237 Sep  9 2003  cuttest
-rw-rw-rw-    1 vbe      bin             101 Sep 17 2003  newterm
-rwxr-xr-x    1 vbe      bin             394 Sep 17 2003  whiletest
-rw-rw-rw-    1 vbe      bin            2920 Sep 17 2003  shell_cpt9
-rw-rw-rw-    1 vbe      bin             121 Sep 18 2003  sendmail_cf.modif
-rw-rw-rw-    1 vbe      bin             626 Sep 18 2003  lvreduce.howto
-rw-rw-rw-    1 vbe      bin            1063 Sep 18 2003  gagatest
-rwxr-xr-x    1 vbe      bin              80 Sep 26 2003  popu
-rwxr-xr-x    1 vbe      bin             718 Sep 30 2003  cpt9test
-rw-rw-rw-    1 vbe      bin              17 Sep 30 2003  errorlog
-rw-rw-rw-    1 vbe      bin             450 Sep 30 2003  usersname
-rw-rw-rw-    1 vbe      bin             128 Sep 14 2004  bufpages.howto
-rw-rw-rw-    1 vbe      bin             136 Sep 27 2004  lup.c
-rwxr-xr-x    1 vbe      bin              92 Sep 27 2004  sh_test3
-rwxr-xr-x    1 vbe      bin              13 Sep 27 2004  sh_test1
-rw-r-----    1 vbe      bin          163448 Sep 28 2004  titi.out
-rw-r--r--    1 vbe      bin          125670 Sep 28 2004  JAVAinfo.out
-rw-rw-rw-    1 vbe      bin             931 Sep 29 2004  mozilla_bug
-rw-rw-rw-    1 vbe      bin            1605 Sep  1 2005  GW_lan_discon.howto
-rw-r--r--    1 vbe      bin            1871 Sep  1 2005  sasperms.logs
-rw-rw-rw-    1 vbe      bin           25940 Sep  2 2005  sasproc_log.log
-rwxr-xr--    1 vbe      bin             321 Sep  7 2005  processor.sh
-rw-rw-rw-    1 vbe      bin              68 Sep  7 2005  node.dat
-rw-rw-rw-    1 vbe      bin             364 Sep  7 2005  node_name_script
-rw-r--r--    1 vbe      bin             136 Sep 12 2005  net_perf_w_glance.howto

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all files by month

Hi, I am trying to do achieving of files by months. find /test -name \*.* -mtime +30 will give me the result of all modified files after 30 days. But lets say i want to list all files that is modified in last months... what is the command to do it? Thanks! (13 Replies)
Discussion started by: maldini
13 Replies

2. Solaris

find files modified in a specific month

hello i need a way to list files modified in a specific month and move them to a specific directry , i mean somthing like : find . -modifiedtime "May" -print -exec /usr/bin/mv newdirectory thank u (1 Reply)
Discussion started by: omer_ome
1 Replies

3. UNIX for Advanced & Expert Users

find files modified in a specific month

hello i need a way to list files modified in a specific month and move them to a specific directry , i mean somthing like : find . -modifiedtime "May" -print -exec /usr/bin/mv newdirectory thank u (1 Reply)
Discussion started by: omer_ome
1 Replies

4. Shell Programming and Scripting

How to find the create time of a file if current date is in next month

Hi All, I want to find the time diffrence between currnt time and "abc.txt" file create time. I have solve that but if the abc.txt file created last month then is there any process to find the difftent? Exp: Create time of abc.txt is "Apr 14 06:48" and currect date is "May 17 23:47".... (1 Reply)
Discussion started by: priyankak
1 Replies

5. UNIX for Dummies Questions & Answers

Reading the dates from a file & moving the files from a directory

Hi All, I am coding for a requirement where I need to read a file & get the values of SUB_DATE. Once the dates are found, i need to move the files based on these dates from one directory to another. ie, this is how it will be in the file, SUB_DATE = 20120608,20120607,20120606,20120606... (5 Replies)
Discussion started by: dsfreddie
5 Replies

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

7. UNIX for Advanced & Expert Users

How to find last two files for a month?

Hi All, I need to find last two files for the month. lets say there are following files in directory -rwxr-xr-x 1 user userg 1596 Mar 19 15:43 c.txt -rwxr-xr-x 1 user userg 1596 Mar 21 15:43 d.txt -rwxr-xr-x 1 user userg 1596 Mar 22 15:43 f.txt -rwxr-xr-x 1... (14 Replies)
Discussion started by: Makarand Dodmis
14 Replies

8. Shell Programming and Scripting

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 -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... (8 Replies)
Discussion started by: Makarand Dodmis
8 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
Calendar::Simple(3pm)					User Contributed Perl Documentation				     Calendar::Simple(3pm)

NAME
Calendar::Simple - Perl extension to create simple calendars SYNOPSIS
use Calendar::Simple; my @curr = calendar; # get current month my @this_sept = calendar(9); # get 9th month of current year my @sept_2002 = calendar(9, 2002); # get 9th month of 2002 my @monday = calendar(9, 2002, 1); # get 9th month of 2002, # weeks start on Monday my @span = date_span(mon => 10, # returns span of dates year => 2006, begin => 15, end => 28); DESCRIPTION
A very simple module that exports one function called "calendar". calendar This function returns a data structure representing the dates in a month. The data structure returned is an array of array references. The first level array represents the weeks in the month. The second level array contains the actual days. By default, each week starts on a Sunday and the value in the array is the date of that day. Any days at the beginning of the first week or the end of the last week that are from the previous or next month have the value "undef". If the month or year parameters are omitted then the current month or year are assumed. A third, optional parameter, start_day, allows you to set the day each week starts with, with the same values as localtime sets for wday (namely, 0 for Sunday, 1 for Monday and so on). date_span This function returns a cur-down version of a month data structure which begins and ends on dates other than the first and last dates of the month. Any weeks that fall completely outside of the date range are removed from the structure and any days within the remaining weeks that fall outside of the date range are set to "undef". As there are a number of parameters to this function, they are passed using a named parameter interface. The parameters are as follows: year The required year. Defaults to the current year if omitted. mon The required month. Defaults to the current month if omitted. begin The first day of the required span. Defaults to the first if omitted. end The last day of the required span. Defaults to the last day of the month if omitted. start_day Indicates the day of the week that each week starts with. This takes the same values as the optional third parameter to "calendar". The default is 0 (for Sunday). This function isn't exported by default, so in order to use it in your program you need to use the module like this: use Calendar::Simple 'date_span'; EXAMPLE A simple "cal" replacement would therefore look like this: #!/usr/bin/perl -w use strict; use Calendar::Simple; my @months = qw(January February March April May June July August September October November December); my $mon = shift || (localtime)[4] + 1; my $yr = shift || (localtime)[5] + 1900; my @month = calendar($mon, $yr); print " $months[$mon -1] $yr "; print "Su Mo Tu We Th Fr Sa "; foreach (@month) { print map { $_ ? sprintf "%2d ", $_ : ' ' } @$_; print " "; } A version of this example, called "pcal", is installed when you install this module. Date Range This module will make use of DateTime.pm if it is installed. By using DateTime.pm it can use any date that DateTime can represent. If DateTime is not installed it uses Perl's built-in date handling and therefore can't deal with dates before 1970 and it will also have problems with dates after 2038 on a 32-bit machine. EXPORT "calendar" AUTHOR
Dave Cross <dave@mag-sol.com> ACKNOWLEDGEMENTS
With thanks to Paul Mison <cpan@husk.org> for the start day patch. COPYRIGHT
Copyright (C) 2002-2008, Magnum Solutions Ltd. All Rights Reserved. LICENSE
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl, localtime, DateTime perl v5.10.1 2010-04-02 Calendar::Simple(3pm)
All times are GMT -4. The time now is 11:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy