Sponsored Content
Top Forums Shell Programming and Scripting delete file older than N days Post 302126601 by bigearsbilly on Thursday 12th of July 2007 05:49:01 AM
Old 07-12-2007
if you need to be really precise I usually do summink like:

Code:
touch -t YYYYMMDDhhmmss 111
find . -older 111 | xargs rm

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Delete user file(s) older then 'X' days ??

I want to delete any file in unix file system which is older then a week. Those files should not be unix system file..means it should be user created file. Any clue to this ?? ASAP. Thanks. (2 Replies)
Discussion started by: varungupta
2 Replies

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

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

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

5. Shell Programming and Scripting

To delete logs older than 30 days

I want to write a shell script that deletes all log files in a directory that are older than 30 days except for 3 files: I am using the following command: find /tmp/logs -name "*.log" -mtime +30 -exec rm -f {} \;But this command deletes all the log files. How can i modify this script that... (5 Replies)
Discussion started by: mmunir
5 Replies

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

7. UNIX for Dummies Questions & Answers

Delete file older than three days

I am using SFTP to transmit files from the Mainframe to an UNIX server. I am looking for some kind of script that runs with SFTP to delete tranmitted files older than 3 days. Can this be done in a SFTP transmission batch job? (5 Replies)
Discussion started by: Steve Carlson
5 Replies

8. Shell Programming and Scripting

Delete logs older than 60 days

i am using HP-UX OS...... delete logs older than 60 days find -mtime +60 | grep -i '.*log' | xargs rm -mtime is nt available in HP-UX, pls tell me other option ? (2 Replies)
Discussion started by: only4satish
2 Replies

9. Shell Programming and Scripting

List and Delete Files which are older than 7 days, but have white spaces in file name

I need to list and delete all files in current older which are olderthan 7 days. But my file names have white spaces. Before deleting I want to list all the files, so that I can verify.find . -type f -mtime +7 | xargs ls -l {} But the ls command is the working on the files which have white... (16 Replies)
Discussion started by: karumudi7
16 Replies

10. Shell Programming and Scripting

Search 2 days older file and then delete last 10 lines

I want to search 2 day older file and then delete last 10 line of that file. (2 Replies)
Discussion started by: sonu pandey
2 Replies
edinplace(1)							Mail Avenger 0.8.3						      edinplace(1)

NAME
edinplace - edit a file in place SYNOPSIS
edinplace [--error=code] [[--file=file] command [arg ...]] DESCRIPTION
edinplace runs command with its input from file (or standard input by default), and then replaces the contents of file with the output of command. To the extent possible, edinplace attempts to exit with the same status as command. If edinplace is run on standard input (no --file option), it must inherit a file descriptor 0 that is open for both reading and writing. When processing standard input, if edinplace does not encounter a fatal error, it rewinds its standard input to offset 0 before exiting. Thus, a script can first run edinplace command, then run another filter command such as grep, and the resulting output will be the output of grep on command's output. If no command is specified, edinplace just rewinds its standard input to file offset 0. In this case, it is an error to supply the --file option. Of course, rewinding only works when standard input is a real file (as opposed to a pipe or device). There are two options: --error=code (-x code) Ordinarily, edinplace attempts to exit with the same status as command. However, if edinplace encounters some fatal error (such as being unable to execute command), it will exit with status code. The default value is 1. The range of valid exit codes is 1-255, inclusive. --file=file (-f file) Specifies that file should be edited. Otherwise, edinplace will edit its standard input (which must be opened for both reading and writing). --skipfrom Skip the first line of the file if it starts "From ". If edinplace is run without a command, positions the file offset at the start of the second line of the file. If edinplace is run with a command, then the first line of the file is neither fed to the command, nor overwritten. This option is useful for running edinplace over mail files, which sometimes start with a "From " line specifying the envelope sender of the message. Since "From " is not part of the message header, just a Unix convention, some programs are confused by the presence of that line. Note that if you specify a command, then edinplace resets the file offset to 0 upon exiting, even if the --skipfrom option was present. EXAMPLES
The following command prepends the string "ORIGINAL: " to the beginning of each line in text file message: edinplace -f message sed -e 's/^/ORIGINAL: /' The following command runs the spamassassin mail filter program on a mail message stored in file message, replacing the contents of message with spamassassin's annotated output, and exiting with code 100 if spamassassin thinks the message is spam. If edinplace encounters any fatal errors, it will exit with code 111. edinplace -x 111 -f message spamassassin -e 100 (spamassassin reads a mail message on standard input and outputs an annotated copy of the message including information about whether or not the message is likely to be spam and why. The -e option to spamassassin specifies what exit status spamassassin should use if the message appears to be spam; edinplace will use the same exit code as the program it has run.) To run spamassassin on incoming mail before accepting the mail from the remote client, place the following line in an appropriate Mail Avenger rcpt file as the last command executed: bodytest edinplace -x 111 spamassassin -e 100 SEE ALSO
avenger(1) The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
edinplace does not make a copy of the file being edited, but rather overwrites the file as it is being processed. At any point where command has produced more output than it has consumed input from the file, edinplace buffers the difference in memory. Thus, a command that outputs large amounts of data before reading the input file can run edinplace out of memory. (A program that outputs data as it reads even a very large file should be fine, however.) If command crashes or malfunctions for any reason, you will likely lose the input file, since edinplace will view this as a program that simply outputs the empty file. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 edinplace(1)
All times are GMT -4. The time now is 02:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy