Login or Register to Ask a Question and Join Our Community

Sponsored Content
Full Discussion: Find files newer than x days
Top Forums UNIX for Dummies Questions & Answers Find files newer than x days Post 302492491 by jim mcnamara on Monday 31st of January 2011 03:57:40 PM
Old 01-31-2011
The second one says ~/DATAFILE, the first ~/DATEFILE

My example assumed:
the file named dummy was in the current working directory

# more explicit example
find /path/to/files -newer ./dummy -type f -exec ls -la

This finds regular files: -type f

Consider following the example, if there is confusion. The example I gave you works on any POSIX-compliant UNIX.
The construction of a find query in the example above is:
find [path is required] -newer [exact path to file ] -type [one of -l -f -d] -exec [shell command required]
-l = link
-d = directory
-f = regular file

Last edited by jim mcnamara; 01-31-2011 at 05:02 PM..

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find files newer than...

Is there a way to use the find command to locate files newer than a specific date? Thanks! --Alex (4 Replies)
Discussion started by: vertigo23
4 Replies

2. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies

3. Shell Programming and Scripting

find files from the past 7 days

Hi All, I have a file which contains the listing of another directory: >cat list.dat -rwxr-xr-x 1 test staff 10240 Oct 02 06:53 test.txtdd -rwxrwxrwx 1 test staff 0 Oct 04 07:22 test.txx -rwxrwxrwx 1 test staff 132 Sep 16 2007 test_tt.sh... (6 Replies)
Discussion started by: deepakgang
6 Replies

4. Shell Programming and Scripting

How to find files older than 30 days

Dear Friends, I have two queries. 1) I want to see the list of folders which were created 29 days ago. 2) I want to see the folders in which last created file is older than 29 days. Can it be done? Thank you in advance Anushree (4 Replies)
Discussion started by: anushree.a
4 Replies

5. UNIX Desktop Questions & Answers

Find files older than 10 days

What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. find . -type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. (4 Replies)
Discussion started by: Pouchie1
4 Replies

6. UNIX for Dummies Questions & Answers

How to find files created some days before?

HI, I have 2 questions. 1> Is there any code to see files that created some day or some time before in a directory??? 2> how or where i will find the last exit status of a process?? thanks (6 Replies)
Discussion started by: jyotidas
6 Replies

7. Shell Programming and Scripting

Find last 2 days files.

Need to cpy those files which are created or modified in last 2 days. bash$ ll -lrt total 184 drwxr-xr-x 2 ons dce 256 Oct 12 06:58 files -rw-r--r-- 1 ons dce 4313 Oct 14 06:06 cab.ksh -rw-r--r-- 1 ons dce 6 Oct 14 07:03 Code.txt... (2 Replies)
Discussion started by: saluja.deepak
2 Replies

8. Shell Programming and Scripting

what is the find to command to find the files created last 30 days

what is the find to command to find the files created last 30 days (5 Replies)
Discussion started by: rajkumar_g
5 Replies

9. UNIX for Advanced & Expert Users

find files older than 30 days old

Hello, I have a script which finds files in a directory that are older than 30 days and remove them. The problem is that these files are too many and when i run this command: find * -mtime +30 | xargs rm I run this command inside the directory and it returns the error: /usr/bin/find:... (8 Replies)
Discussion started by: omonoiatis9
8 Replies

10. Shell Programming and Scripting

Find the sum of files created 5 days before

Hi, I want to find the sum of all the files created 5 days ago and store it in a variable. (os is HP-UX) can this be extracted from ls -l Is there any other way of getting the sum of all the files created (4 Replies)
Discussion started by: bang_dba
4 Replies
FIND(1) 						      General Commands Manual							   FIND(1)

find - find files SYNOPSIS
find pathname-list expression find pattern DESCRIPTION
In the first form above, find recursively descends the directory hierarchy for each pathname in the pathname-list (i.e., one or more path- names) seeking files that match a boolean expression written in the primaries given below. In the descriptions, the argument n is used as a decimal integer where +n means more than n, -n means less than n and n means exactly n. The second form rapidly searches a database for all pathnames which match pattern. Usually the database is recomputed weekly and contains the pathnames of all files which are publicly accessible. If escaped, normal shell "globbing" characters (`*', `?', `[', and ']') may be used in pattern, but the matching differs in that no characters (e.g. `/') have to be matched explicitly. As a special case, a simple pat- tern containing no globbing characters is matched as though it were *pattern*; if any globbing character appears there are no implicit globbing characters. -name filename True if the filename argument matches the current file name. Normal shell argument syntax may be used if escaped (watch out for `[', `?' and `*'). -perm onum True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is prefixed by a minus sign, more flag bits (017777, see stat(2)) become significant and the flags are compared: (flags&onum)==onum. -type c True if the type of the file is c, where c is b, c, d, f, l or s for block special file, character special file, directory, plain file, symbolic link, or socket. -links n True if the file has n links. -user uname True if the file belongs to the user uname (login name or numeric user ID). -nouser True if the file belongs to a user not in the /etc/passwd database. -group gname True if the file belongs to group gname (group name or numeric group ID). -nogroup True if the file belongs to a group not in the /etc/group database. -size n True if the file is n blocks long (512 bytes per block). -inum n True if the file has inode number n. -atime n True if the file has been accessed in n days. -mtime n True if the file has been modified in n days. -exec command True if the executed command returns a zero value as exit status. The end of the command must be punctuated by an escaped semi- colon. A command argument `{}' is replaced by the current pathname. -ok command Like -exec except that the generated command is written on the standard output, then the standard input is read and the command executed only upon response y. -print Always true; causes the current pathname to be printed. -ls Always true; causes current pathname to be printed together with its associated statistics. These include (respectively) inode number, size in kilobytes (1024 bytes), protection mode, number of hard links, user, group, size in bytes, and modification time. If the file is a special file the size field will instead contain the major and minor device numbers. If the file is a symbolic link the pathname of the linked-to file is printed preceded by ``->''. The format is identical to that of ``ls -gilds'' (note however that formatting is done internally, without executing the ls program). -newer file True if the current file has been modified more recently than the argument file. -cpio file Write the current file on the argument file in cpio format. -xdev Always true; causes find not to traverse down into a file system different from the one on which current argument pathname resides. The primaries may be combined using the following operators (in order of decreasing precedence): 1) A parenthesized group of primaries and operators (parentheses are special to the Shell and must be escaped). 2) The negation of a primary (`!' is the unary not operator). 3) Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries). 4) Alternation of primaries (`-o' is the or operator). EXAMPLES
To find all accessible files whose pathname contains `find': find find To typeset all variants of manual pages for `ls': vtroff -man `find '*man*/ls.?'` To remove all files named `a.out' or `*.o' that have not been accessed for a week: find / ( -name a.out -o -name '*.o' ) -atime +7 -exec rm {} ; FILES
/etc/passwd /etc/group /var/db/find.codes coded pathnames database SEE ALSO
sh(1), test(1), fs(5) Relevant paper in February, 1983 issue of ;login:. BUGS
The first form's syntax is painful, and the second form's exact semantics is confusing and can vary from site to site. More than one `-newer' option does not work properly. 7th Edition October 11, 1996 FIND(1)

Featured Tech Videos