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
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.