Sponsored Content
Top Forums Shell Programming and Scripting How to find all files other than last two dates per month and year? Post 302899278 by Makarand Dodmis on Monday 28th of April 2014 11:59:01 AM
Old 04-28-2014
How to find all files other than last two dates per month and year?

Hi All,
lets say there are following files in directory
Code:
-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
-rwxr-xr-x   1 user  userg         1596 Mar 25 2012 e.txt
-rwxr-xr-x   1 user  userg         1596 Mar 25 2012 eio.txt
-rwxr-xr-x   1 user  userg         1596 Mar 27 2012 ee.txt
-rwxr-xr-x   1 user  userg         1596 Feb 12 2012 f.txt
-rwxr-xr-x   1 user  userg         1596 Feb 12 2012 g.txt
-rwxr-xr-x   1 user  userg         1596 Feb 22 2012 h.txt
-rwxr-xr-x   1 user  userg         1596 Feb 23 2012 i.txt
-rwxr-xr-x   1 user  userg         1596 Feb 28 2012 j.txt
-rwxr-xr-x   1 user  userg         1596 Feb 28 2012 jj.txt
-rwxr-xr-x   1 user  userg         1596 Apr 02 2013 k.txt
-rwxr-xr-x   1 user  userg         1596 Apr 11 2013 l.txt
-rwxr-xr-x   1 user  userg         1596 Apr 11 2013 m.txt
-rwxr-xr-x   1 user  userg         1596 Apr 23 2013 n.txt
-rwxr-xr-x   1 user  userg         1596 Apr 27 2013 o.txt
-rwxr-xr-x   1 user  userg         1596 Apr 29 2013 oo.txt

for Mar 2012
last two dates are Mar25 & Mar27

for Feb 2012
last two dates are Feb28 & Feb23

for Apr 2012
last two dates are Apr27 & Apr29

So i want all files in directory other than above dates which are in red colour

output should be:
Code:
-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
-rwxr-xr-x   1 user  userg         1596 Feb 12 2012 f.txt
-rwxr-xr-x   1 user  userg         1596 Feb 12 2012 g.txt
-rwxr-xr-x   1 user  userg         1596 Feb 22 2012 h.txt
-rwxr-xr-x   1 user  userg         1596 Apr 02 2013 k.txt
-rwxr-xr-x   1 user  userg         1596 Apr 11 2013 l.txt
-rwxr-xr-x   1 user  userg         1596 Apr 11 2013 m.txt
-rwxr-xr-x   1 user  userg         1596 Apr 23 2013 n.txt

---------- Post updated at 10:59 AM ---------- Previous update was at 09:02 AM ----------

guys Any help??

Last edited by Makarand Dodmis; 04-28-2014 at 12:58 PM..
 

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

5. Shell Programming and Scripting

Julian day to dates in YEAR-MONTH-DAY

hello, I have many files called day001, day002, day003 and I want to rename them by day20070101, day20070102, etc. I need to do it for several years and leap years as well. What is the best way to do it ? Thank you. (1 Reply)
Discussion started by: Ggg
1 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

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

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
dos2unix(1)						      General Commands Manual						       dos2unix(1)

NAME
dos2unix - DOS/MAC to UNIX text file format converter SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates dos2unix under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. dos2unix Convert and replace a.txt. Convert and replace b.txt. dos2unix a.txt b.txt dos2unix -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format. dos2unix a.txt -c iso b.txt dos2unix -c ascii a.txt -c iso b.txt dos2unix -c mac a.txt b.txt Convert and replace a.txt while keeping original date stamp. dos2unix -k a.txt dos2unix -k -o a.txt Convert a.txt and write to e.txt. dos2unix -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. dos2unix -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. dos2unix a.txt -n b.txt e.txt dos2unix -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org> MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
unix2dos(1) mac2unix(1) 1995.03.31 dos2unix v3.0 dos2unix(1)
All times are GMT -4. The time now is 08:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy