Removing certain files after certain days..


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Removing certain files after certain days..
# 1  
Old 09-26-2011
Removing certain files after certain days..

Hi guys..

Currently me using AIX 5.3.0.0

I have these files generated by Oracle in /tmp folder..

# date
Mon Sep 26 11:53:31 BEIST 2011
# pwd
/tmp
# df -g .
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd3 10.00 3.65 64% 62479 7% /tmp
# ls -l |wc -l
61717
# find . -mtime +30 -print|xargs ls -l|wc -l
56070
# find . -mtime +30 -print|xargs ls -al|grep Tkttrans| wc -l
54103

How can I delete only the Tkttrans*.tmp files from the folder.

If I use this command, it would delete all the files after 30 days period..
find . -mtime +30 -print|xargs rm

I tried this but encounter error..
# find . -mtime +30 -print|xargs rm Tkttrans*.tmp
ksh: /usr/bin/xargs: 0403-027 The parameter list is too long.

Please advice..
# 2  
Old 09-26-2011
Code:
find . -mtime +30 -name 'Tkttrans*.tmp' -print | xargs rm

This User Gave Thanks to yazu For This Post:
# 3  
Old 09-26-2011
hey.. it works...

thanks.. was thinking about missing some parameters... but didn't realise you have to put the argument in front..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need files exactly 3 to 7 days old

Hi, I need files exactly 3 to 7 days old. Today is 28th July 2016. I have two files one dated 25th July and other 21st July which are 3 to 7 days old. 94702 1 -rw-r--r-- 1 m1083 user1 26 Jul 25 13:00 ./Report_0751.txt 94751 1 -rw-r--r-- 1 m1083 user1 128 Jul... (4 Replies)
Discussion started by: mohtashims
4 Replies

2. Shell Programming and Scripting

How can i list files above 5 days old?

HI how can i list files above 5 days old i want to keep only last 5 days application logs Regards, Ben (3 Replies)
Discussion started by: bentech4u
3 Replies

3. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

4. UNIX for Dummies Questions & Answers

Need Help in reading N days files from a Directory & combining the files

Hi All, Request your expertise in tackling one requirement in my project,(i dont have much expertise in Shell Scripting). The requirement is as below, 1) We store the last run date of a process in a file. When the batch run the next time, it should read this file, get the last run date from... (1 Reply)
Discussion started by: dsfreddie
1 Replies

5. UNIX for Advanced & Expert Users

removing files older than n days

Hi, on AIX 6.1, is there any commande line to remove the files older than n days in a directory ? Thanks. (2 Replies)
Discussion started by: big123456
2 Replies

6. Shell Programming and Scripting

help with removing files which are n days old

Hi , I need to remove files from a specific directory which are 7 days old using folowing find comand as: find /home/dir1/log -name "run*.log" -mtime +6 -prune -exec rm -f {} \; but my script should traverse to /home/dir1/log and them delete the specified files in the directory. i.e... (2 Replies)
Discussion started by: Navatha
2 Replies

7. UNIX for Dummies Questions & Answers

Removing files older than 7 days

Script help, I need to delete files that are older than 7 days. I do that automatically but I know that a cron job can do the job for me. Any help is greatly appreciated, as you can see, I am a DOS or WINDOWS guy. Little on UNIX. Thanks (3 Replies)
Discussion started by: texasoeb
3 Replies

8. Shell Programming and Scripting

ls latest 4 days or specify days of files in the directory

Hi, I would like to list latest 2 days, 3 days or 4 days,etc of files in the directory... how? is it using ls? (3 Replies)
Discussion started by: happyv
3 Replies

9. Shell Programming and Scripting

Removing files automatically from a directory after 30 days.

Hello; I have a directory that is collecting log and act files. I need to write a script that will remove these files once they are 30 days old. I have read through a number of threads on this site that have given me a great deal of information. However I have what seems to be a unique... (7 Replies)
Discussion started by: justinb_155
7 Replies

10. Shell Programming and Scripting

removing files that are 60 days old

Hello guys I'm writing a script and I need some help. I'm almost done but I think I have a problem with my ffind command. I need the scripts to delete files are 60 days old and then append the filenames to a text file on the days they were deleted. If someone can help me I would be thankful. (5 Replies)
Discussion started by: aojmoj
5 Replies
Login or Register to Ask a Question