Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to delete files which are 7 days old Post 1959 by arunava_maity on Tuesday 10th of April 2001 07:54:25 AM
Old 04-10-2001
Hi all,
how to write a script that will indentify the files in a directory which are 7 days old and delete those files.
Thanks in advance
Cheers
Arunava
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete files older than 7 days

can anyone tell me how I would write a script in ksh on AIX that will delete files in a directory older than 7 days? (1 Reply)
Discussion started by: lesstjm
1 Replies

2. UNIX for Dummies Questions & Answers

How can I delete files older than 7 days?

I will like to write a script that delete all files that are older than 7 days in a directory and it's subdirectories. Can any one help me out witht the magic command or script? Thanks in advance, Odogboly98:confused: (3 Replies)
Discussion started by: odogbolu98
3 Replies

3. UNIX for Dummies Questions & Answers

How to delete files over 30 days

I have a directory that contains files. I would like the command that deletes all files that are over 30 days old. Delete files based on creation date and not modified. (2 Replies)
Discussion started by: GEBRAUN
2 Replies

4. UNIX for Dummies Questions & Answers

how can i delete last 7 days mofified files

how can i delete last 7 days mofified files(need command please...........) (3 Replies)
Discussion started by: ss4u
3 Replies

5. UNIX for Dummies Questions & Answers

Delete files older than 30 days

This is driving me crazy. How can I delete files in a specifc directory that are over 30 days old? Thanks in advance. (3 Replies)
Discussion started by: tlphillips
3 Replies

6. Shell Programming and Scripting

delete files more than 15 days older

i have to delete files which are older than 15 days or more except the ones in the directory Current and also *.sh files i have found the command for files 15 days or more older find . -type f -mtime +15 -exec ls -ltr {} \; but how to implement the logic to avoid directory Current and also... (3 Replies)
Discussion started by: ali560045
3 Replies

7. Shell Programming and Scripting

Delete files from sub-directories over 7 days

Can any one please help me in deleting all the Files over 7 days from sub-directories A, B, C... Top-Directory Sub-Directory-A File-1 File-2 ..... File-n Sub-Directory-B File-1 File-2 ..... File-n Sub-Directory-C File-1 ... (1 Reply)
Discussion started by: sureshcisco
1 Replies

8. Solaris

Delete files older than 30 days

Hi all, I want to delete log files with extension .log which are older than 30 days. How to delete those files? Operating system -- Sun solaris 10 Your input is highly appreciated. Thanks in advance. Regards, Williams (2 Replies)
Discussion started by: William1482
2 Replies

9. Shell Programming and Scripting

Delete files older than X days.

Hi All, I am using below code to delete files older than 2 days. In case if there are no files, I should log an error saying no files to delete. Please let me know, How I can achive this. find /path/*.xml -mtime +2 Thanks and Regards Nagaraja. (3 Replies)
Discussion started by: Nagaraja Akkiva
3 Replies

10. Shell Programming and Scripting

Delete files 30 days old

Will this work to delete files 30 days old in $backupDir or is there a better way to do it? find $backupDir -type f -mtime +30 -exec rm {} \; (2 Replies)
Discussion started by: wyclef
2 Replies
find(1) 						      General Commands Manual							   find(1)

Name
       find - find files

Syntax
       find pathname-list  expression

Description
       The  command  recursively  descends the directory hierarchy for each pathname in the pathname-list (that is, one or more pathnames) seeking
       files that match a boolean expression written in the primaries given below.  In the descriptions, the argument n is used as a decimal inte-
       ger where +n means more than n, -n means less than n , and n means exactly n.

Options
       -atime n       Tests true if the file has been accessed in n days.

       -cpio output   Writes current file on output in the format (5120-byte records) specified in the reference page.	The output can be either a
		      file or tape device.  If output is a tape device the B key must be used to read data from the tape.

       -ctime n       Tests true if the file has been changed in n days.

       -depth	      Always true; causes descent of the directory hierarchy to be done so that all entries in a directory are acted on before the
		      directory  itself (that is, postorder instead of preorder).  This can be useful when is used with to transfer files that are
		      contained in directories without write permission.

       -exec command  Tests true if specified command returns a 0 on exit.  The end of the command must be punctuated by an escaped semicolon.	 A
		      command argument `{}' is replaced by the current pathname.

       -group gname   Tests true if group ID matches specified group name.

       -inum n	      Tests true if the file has inode number n.

       -links n       Tests true if the file has n links.

       -mount	      Tests true if the current file is on the same file system as the current starting pathname.

       -mtime n       Tests true if the file has been modified in n days.

       -name filename Tests  true  if  the  filename  argument matches the current file name.  Normal Shell argument syntax may be used if escaped
		      (watch out for `[', `?' and `*').

       -newer file    Tests true if the current file has been modified more recently than the argument file.

       -ok command    Executes specified command on standard output, then standard input is read and command executed only upon response y.

       -perm onum     Tests true if file has specified octal number.  For further information, see If onum is prefixed by a minus sign, more  flag
		      bits (017777) become significant and the flags are compared: (flags&onum)==onum.	For further information, see

       -print	      Prints current pathname.

       -size n	      Tests true if the file is n blocks long (512 bytes per block).

       -type c	      Tests  true  if  file is c type ( c = b, block special file: c, character special file: d, directory: f, plain file: l, sym-
		      bolic link: p, type port: s, type socket).

       -user uname    Tests true if file owner is login name or numeric user ID.

       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 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 {} ;

       To find all files on the root file system type:
       find / -mount -print

       To write all the files on the root file system to tape:
       find / -mount -print -cpio /dev/rmt?h
       cpio -iBvt < /dev/rmt?h

       To find all the mount points on the root file system type:
       find / ! -mount -print

Files
See Also
       cpio(1), sh(1), test(1), cpio(5), fs(5)

																	   find(1)
All times are GMT -4. The time now is 08:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy