Need to remove *.aud files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to remove *.aud files
# 1  
Old 03-05-2014
Need to remove *.aud files

Hello,

I am gettig belwo error while deleting files:

Code:
 find /prodoragridcn_01/app/oracle/product/10204/rdbms/audit/*.aud -mtime +60 -exec rm{}\;
ksh: /usr/bin/find: arg list too long

Please assist.

Best regards,
Vishal

Moderator's Comments:
Mod Comment Thread moved. Please do not post general scripting questions in the AIX forum. Feel free to mention that you are using AIX in your question, but post scripting questions in the appropriate sub-forum. Thank you.

Last edited by Scott; 03-06-2014 at 07:28 AM.. Reason: Moved thread
# 2  
Old 03-05-2014
Try

Code:
find /prodoragridcn_01/app/oracle/product/10204/rdbms/audit/*.aud -mtime +60 | xargs -l rm

--ahamed
# 3  
Old 03-05-2014
This is also giving the same error

Code:
 find /prodoragridcn_01/app/oracle/product/10204/rdbms/audit/*.aud -mtime +60 | xargs -l -I {} rm {}
ksh: /usr/bin/find: arg list too long

Best regards,
Vishal
# 4  
Old 03-05-2014
I guess you need to modify the find command then, try this

Code:
find /prodoragridcn_01/app/oracle/product/10204/rdbms/audit/ -name "*.aud" -type f -mtime +60 -delete

--ahamed
# 5  
Old 03-05-2014
Code:
find /prodoragridcn_01/app/oracle/product/10204/rdbms/audit/ -name "*.aud" -type f -mtime +60 -delete
find: bad option -delete


This is AIX os.



Best regards,
Vishal
# 6  
Old 03-05-2014
Use the -exec option then

Code:
find /prodoragridcn_01/app/oracle/product/10204/rdbms/audit/ -name "*.aud" -type f -mtime +60 -exec rm {} \;

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 7  
Old 03-06-2014
Vishal_dba,

The problem here is that the shell is expanding your command before executing, so if it's going to match one file, it's probably fine. Matching 20 will be a problem as you will actually execute:-
Code:
find file1 file2 file3 file4............file20 -type f -mtime +60 -exec rm {} \;

Of course, you might match 5000 files. This is why giving the directory name only as the first parameter to find and using the -name "*.aud" arguments will be far better. This tels it to search from one location and match files (directories, pipes, etc.) based on your expression. That actual command executed is as seen, without expansion. Remember to keep *.aud quoted.


I hope that this explanation helps show why ahamed101 has a good solution.




Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Update remove files

Howdy. I'm currently hoping to putty to a number of Linux VMs and update a hosts file remotely before moving on to the next VM in a list. Does anyone have a script that does anything similar? Are there any decent script repositories online? (2 Replies)
Discussion started by: seanbeag
2 Replies

2. Solaris

Command to remove existing files in the tar files in Solaris 10

Hi, I am using solaris 10 OS.Please help me out with the commands needed in below two scenarios. 1)How to delete the existing files in the tar file. suppose i have a main tarfile named application.tar and it contains a file called ingres.tar. what is the command to remove ingres.tar... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

3. Shell Programming and Scripting

Remove old files

In my redhat 5 sysem , there are many files are generated to a directory, I would like to do the housekeeping as following , move the files elder than 90 days to a specific directory , then remove the the files elder than 180 days from this specific directory , I have a script to do it . ... (2 Replies)
Discussion started by: ust3
2 Replies

4. UNIX for Dummies Questions & Answers

Remove files by name

Hi, I have multiple xml files and named 1233__AAA__12.xml 1234__AAA__12.xml 2125__AAA__13.xml 2127__AAA__13.xml and I want to delete or to remove only these with the hightest ID e.g. files 1234__AAA__12.xml and 2127__AAA__13.xml. Could you tell me how can i do that? Is there any script?... (5 Replies)
Discussion started by: corfuitl
5 Replies

5. AIX

Remove BROKEN Files ?

Guy's When I execute lppchk -v I have seen about 9 BROKEN Files lppchk: The following filesets need to be installed or corrected to bring the system to a consistent state: Pls advide how to forcely Remove these BROKEN Files ? (1 Reply)
Discussion started by: Mr.AIX
1 Replies

6. Shell Programming and Scripting

Remove files

I know that rm -i, asks a user before removing a file. What I need to accomplish is removing files from a different directory without switching to that directory. Example: I'm currently in directory dog and I want to remove all the files of a certain name in directory cat, but from within the dog... (5 Replies)
Discussion started by: smiley76112
5 Replies

7. UNIX for Advanced & Expert Users

how to remove the files along with its link files

How to remove the files along with its link files either hardlink or softlink? (1 Reply)
Discussion started by: Ramesh_srk
1 Replies

8. Shell Programming and Scripting

compare two files and to remove the matching lines on both the files

I have two files and need to compare the two files and to remove the matching lines from both the files (4 Replies)
Discussion started by: shellscripter
4 Replies

9. Shell Programming and Scripting

remove files

Hi, How do i remove all the files that are present in the directory.. I know a way of doing this..that is by using *.* .. But my directory has executables or some files without extensions... So they are not getting deleted. What do i do to remove all of them? Thanks, Nisha (7 Replies)
Discussion started by: Nisha
7 Replies
Login or Register to Ask a Question