Reputation: 46
I'm trying to run this command, but get arg list too long error:
find /dir1/dir2/dir3/dir4/dir5 -name *.cdb -type f -mmin +30 -delete
Error is:
/usr/bin/find: Arg list too long.
Probably the find command returns too many files. Any suggestions on how to overcome this issue?
Thanks
Upvotes: 0
Views: 168
Reputation: 5758
Bash globbing is expanding your *.cdb
argument and you are sending too many arguments to the find
command.
Try adding quotes to that argument to avoid shell expansion and pass the globbing task to the find
command:
find /dir1/dir2/dir3/dir4/dir5 -name '*.cdb' -type f -mmin +30 -delete
If you still need to increment the maximum arguments limit, you can use ulimit -s
:
ulimit -s 65536
Upvotes: 0
Reputation: 2831
First off, you should escape the asterisk to prevent the shell from expanding it:
find /dir1/dir2/dir3/dir4/dir5 -name \*.cdb -type f -mmin +30 -delete
or
find /dir1/dir2/dir3/dir4/dir5 -name '*.cdb' -type f -mmin +30 -delete
Upvotes: 1