Sponsored Content
Top Forums Shell Programming and Scripting script to view files based on date Post 85273 by vino on Tuesday 4th of October 2005 09:05:07 AM
Old 10-04-2005
In short RTFM.

From man touch

Code:
       -d, --date=STRING
              parse STRING and use it instead of current time

       -F, --forward=SECONDS
              Modify  the time by going forward SECONDS seconds.  For example,
              touch -r foo -F 5 bar will make the file  bar  5  seconds  newer
              than file foo.

       -r, --reference=FILE
              use this file's times instead of current time

That means create /tmp/OLD which has a timestamp provided by the user.

And then create /tmp/NEW which is exactly 24 hours newer compared to /tmp/OLD

And from man find,

Code:
       -newer file
              File was modified more recently than file.  -newer  is  affected
              by  -follow  only  if -follow comes before -newer on the command
              line.

       -size n[bckw]
              File uses n units of space.  The units are  512-byte  blocks  by
              default  or  if `b' follows n, bytes if `c' follows n, kilobytes
              if `k' follows n, or 2-byte words if `w' follows  n.   The  size
              does  not  count  indirect  blocks,  but it does count blocks in
              sparse files that are not actually allocated.

The find script says -- find all files which are newer than /tmp/OLD but not /tmp/NEW and whose size is not zero.

Vino
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove files based on date

I am trying to write a shell script that will remove files in a directory based on the date. For instance, remove all files older than yesterday. Any ideas? (4 Replies)
Discussion started by: hshapiro
4 Replies

2. Shell Programming and Scripting

Count of files based on date?

Hi Friends, Can anyone help me with this: To get the count of files that are existing in a directory created on a perticular date like in the example (01/08) .(having same pattern for the filename) ex: FileName Creted Date FILE001 01/08/2007 FILE005 ... (6 Replies)
Discussion started by: sbasetty
6 Replies

3. Shell Programming and Scripting

script to search context from 2 files based on date and name

Please Close thread- Thank You. (1 Reply)
Discussion started by: ezmethod
1 Replies

4. Shell Programming and Scripting

Need script to select multiple files from archive directory based on the date range

hi all, here is the description to my problem. input parameters: $date1 & $date2 based on the range i need to select the archived files from the archived directory and moved them in to working directory. can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Discussion started by: bbc17484
3 Replies

5. Shell Programming and Scripting

Deleting the files based on the date's

I have to write one script which will delete the files in the below passion. If today is 17-Feb-2010 then the script delete only 17-JAN-2010 files from the directory. Could you please help me, How will I delete the files when the year is leap year, if today is 30th Mar 2010 then how will... (1 Reply)
Discussion started by: kandi.reddy
1 Replies

6. UNIX for Dummies Questions & Answers

view gzipped files with name file.gz.$DATE on a Solaris box (without unzipping first)

Hi Howto view gzipped files with name file.gz.$DATE on a Solaris box (without unzipping first) $ ls -lrt total 4477 -rwxrwxr-x 1 oracle dba 569745 Apr 4 19:45 4_person2profileCon.txt.gz.04.04.11* -rwxrwxr-x 1 oracle dba 3783 Apr 4 19:45... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

7. Shell Programming and Scripting

How to view files from a specific date/day

I wan to view files in a directory of a specific date. For example a log directory has log files . I want to view the list of the files which were generated on 01-May-2011. Is there any option/proces to perform it?? (1 Reply)
Discussion started by: mady135
1 Replies

8. UNIX for Dummies Questions & Answers

Script moving files based on date

Hi, I need a script that moves files based on date to a folder. The folder should be created based on file date. Example is : Date file name ----- -------- Oct 08 07:39 10112012_073952.xls Oct 09 07:39 10112012_073952.xls Oct 10 07:39 ... (6 Replies)
Discussion started by: rockingvj
6 Replies

9. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

10. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies
Template::Plugin::File(3)				User Contributed Perl Documentation				 Template::Plugin::File(3)

NAME
Template::Plugin::File - Plugin providing information about files SYNOPSIS
[% USE File(filepath) %] [% File.path %] # full path [% File.name %] # filename [% File.dir %] # directory DESCRIPTION
This plugin provides an abstraction of a file. It can be used to fetch details about files from the file system, or to represent abstract files (e.g. when creating an index page) that may or may not exist on a file system. A file name or path should be specified as a constructor argument. e.g. [% USE File('foo.html') %] [% USE File('foo/bar/baz.html') %] [% USE File('/foo/bar/baz.html') %] The file should exist on the current file system (unless "nostat" option set, see below) as an absolute file when specified with as leading '"/"' as per '"/foo/bar/baz.html"', or otherwise as one relative to the current working directory. The constructor performs a "stat()" on the file and makes the 13 elements returned available as the plugin items: dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks e.g. [% USE File('/foo/bar/baz.html') %] [% File.mtime %] [% File.mode %] ... In addition, the "user" and "group" items are set to contain the user and group names as returned by calls to "getpwuid()" and "getgrgid()" for the file "uid" and "gid" elements, respectively. On Win32 platforms on which "getpwuid()" and "getgrid()" are not available, these values are undefined. [% USE File('/tmp/foo.html') %] [% File.uid %] # e.g. 500 [% File.user %] # e.g. abw This user/group lookup can be disabled by setting the "noid" option. [% USE File('/tmp/foo.html', noid=1) %] [% File.uid %] # e.g. 500 [% File.user %] # nothing The "isdir" flag will be set if the file is a directory. [% USE File('/tmp') %] [% File.isdir %] # 1 If the "stat()" on the file fails (e.g. file doesn't exists, bad permission, etc) then the constructor will throw a "File" exception. This can be caught within a "TRY...CATCH" block. [% TRY %] [% USE File('/tmp/myfile') %] File exists! [% CATCH File %] File error: [% error.info %] [% END %] Note the capitalisation of the exception type, '"File"', to indicate an error thrown by the "File" plugin, to distinguish it from a regular "file" exception thrown by the Template Toolkit. Note that the "File" plugin can also be referenced by the lower case name '"file"'. However, exceptions are always thrown of the "File" type, regardless of the capitalisation of the plugin named used. [% USE file('foo.html') %] [% file.mtime %] As with any other Template Toolkit plugin, an alternate name can be specified for the object created. [% USE foo = file('foo.html') %] [% foo.mtime %] The "nostat" option can be specified to prevent the plugin constructor from performing a "stat()" on the file specified. In this case, the file does not have to exist in the file system, no attempt will be made to verify that it does, and no error will be thrown if it doesn't. The entries for the items usually returned by "stat()" will be set empty. [% USE file('/some/where/over/the/rainbow.html', nostat=1) [% file.mtime %] # nothing METHODS
All "File" plugins, regardless of the "nostat" option, have set a number of items relating to the original path specified. path The full, original file path specified to the constructor. [% USE file('/foo/bar.html') %] [% file.path %] # /foo/bar.html name The name of the file without any leading directories. [% USE file('/foo/bar.html') %] [% file.name %] # bar.html dir The directory element of the path with the filename removed. [% USE file('/foo/bar.html') %] [% file.name %] # /foo ext The file extension, if any, appearing at the end of the path following a '"."' (not included in the extension). [% USE file('/foo/bar.html') %] [% file.ext %] # html home This contains a string of the form '"../.."' to represent the upward path from a file to its root directory. [% USE file('bar.html') %] [% file.home %] # nothing [% USE file('foo/bar.html') %] [% file.home %] # .. [% USE file('foo/bar/baz.html') %] [% file.home %] # ../.. root The "root" item can be specified as a constructor argument, indicating a root directory in which the named file resides. This is otherwise set empty. [% USE file('foo/bar.html', root='/tmp') %] [% file.root %] # /tmp abs This returns the absolute file path by constructing a path from the "root" and "path" options. [% USE file('foo/bar.html', root='/tmp') %] [% file.path %] # foo/bar.html [% file.root %] # /tmp [% file.abs %] # /tmp/foo/bar.html rel(path) This returns a relative path from the current file to another path specified as an argument. It is constructed by appending the path to the '"home"' item. [% USE file('foo/bar/baz.html') %] [% file.rel('wiz/waz.html') %] # ../../wiz/waz.html EXAMPLES
[% USE file('/foo/bar/baz.html') %] [% file.path %] # /foo/bar/baz.html [% file.dir %] # /foo/bar [% file.name %] # baz.html [% file.home %] # ../.. [% file.root %] # '' [% file.abs %] # /foo/bar/baz.html [% file.ext %] # html [% file.mtime %] # 987654321 [% file.atime %] # 987654321 [% file.uid %] # 500 [% file.user %] # abw [% USE file('foo.html') %] [% file.path %] # foo.html [% file.dir %] # '' [% file.name %] # foo.html [% file.root %] # '' [% file.home %] # '' [% file.abs %] # foo.html [% USE file('foo/bar/baz.html') %] [% file.path %] # foo/bar/baz.html [% file.dir %] # foo/bar [% file.name %] # baz.html [% file.root %] # '' [% file.home %] # ../.. [% file.abs %] # foo/bar/baz.html [% USE file('foo/bar/baz.html', root='/tmp') %] [% file.path %] # foo/bar/baz.html [% file.dir %] # foo/bar [% file.name %] # baz.html [% file.root %] # /tmp [% file.home %] # ../.. [% file.abs %] # /tmp/foo/bar/baz.html # calculate other file paths relative to this file and its root [% USE file('foo/bar/baz.html', root => '/tmp/tt2') %] [% file.path('baz/qux.html') %] # ../../baz/qux.html [% file.dir('wiz/woz.html') %] # ../../wiz/woz.html AUTHORS
Michael Stevens wrote the original "Directory" plugin on which this is based. Andy Wardley split it into separate "File" and "Directory" plugins, added some extra code and documentation for "VIEW" support, and made a few other minor tweaks. COPYRIGHT
Copyright 2000-2007 Michael Stevens, Andy Wardley. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, Template::Plugin::Directory, Template::View perl v5.16.3 2011-12-20 Template::Plugin::File(3)
All times are GMT -4. The time now is 08:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy