Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

/usr/bin/find: Argument list too long error

SOLVED
Go to solution
Leah Chow
Frequent Advisor

/usr/bin/find: Argument list too long error

I have a script to delete all the old oracle trace files, if the files are more than 30 days old.

find *.trc -mtime +$DAY_AFTER -exec rm {} \;

but when i execute this command, i got ' Argument list too long' error, could someone help me on this?

Thanks for your hlep
Leah
8 REPLIES
Heironimus
Honored Contributor
Solution

Re: /usr/bin/find: Argument list too long error

It's because you have lots of .trc files and the shell is expanding that "*.trc" to a list that's longer than find can handle. You probably want something like this:

find . -name '*.trc' -maxdepth 1 ....
Court Campbell
Honored Contributor

Re: /usr/bin/find: Argument list too long error

I would assume it is because you never gave it a path.

find [insert_path_here] *.trc -mtime +$DAY_AFTER -exec rm {} \;
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Leah Chow
Frequent Advisor

Re: /usr/bin/find: Argument list too long error

actually before this find command, i have a
cd to the $PATH.

I am wondering whether i should change the system parameter or not?

Court Campbell
Honored Contributor

Re: /usr/bin/find: Argument list too long error

Even if you cd to the path you would need to put a "." for the path in the find statement. Otherwise it thinks that the path is *.trc, ehich could be "Argument list too long".
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Leah Chow
Frequent Advisor

Re: /usr/bin/find: Argument list too long error

still doesn't work even after i added the path.

thanks
Leah
Court Campbell
Honored Contributor

Re: /usr/bin/find: Argument list too long error

jeez, you need to use -name also. look at Heironimus' example. here:

find . -name '*.trc' -mtime +$DAY_AFTER -exec rm {} \;
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Court Campbell
Honored Contributor

Re: /usr/bin/find: Argument list too long error

and ok, you technically don't need to put the "." for the path. I just think it makes it easier for others to understand where the find command is searching.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Leah Chow
Frequent Advisor

Re: /usr/bin/find: Argument list too long error

thanks, i did add the maxdepth 1 , but i didn't pay attention on the -name, now it works, thanks a lot for your help.