Oracle Linux 5.10
BASH shell
[oracle@src01]$ getconf ARG_MAX
131072
[oracle@srv01]$ ls -1 | wc -l
40496
#!/bin/bash
#
# delete files in /imr_report_repo that are older than 15-days
find /imr_report_repo/* -maxdepth 0 -type f -mtime +15 |
while read file
do
rm -f $file
done
/usr/bin/find: Argument list too long
If I'm reading this right the maximum arguments allowed is 131,072 and I only have 40,496 files in this directory. I haven't checked, but I'm probably trying to delete 40,000 files (over 2-weeks old).
*
(why would you need that ?) and retry. I'm not sure why you need thewhile..read
loop either... – don_crissti Mar 02 '16 at 20:53find /imr_report_repo/ -maxdepth 1 -type f -mtime +15 -exec rm {} +
. or if you're trying to delete files in immediate sub-directories of/imr_report_repo/
(but not /imr_report_repo itself) then usefind /imr_report_repo/*/ -maxdepth 0 -type f -mtime +15 -exec rm {} +
- note the trailing/
(but note also that this is also subject to ARG_MAX limit of 128Kbytes). – cas Mar 02 '16 at 21:02-delete
option not available in yourfind
? – FelixJN Mar 02 '16 at 21:48maxdepth
because it's only available where/whendelete
is available too... – don_crissti Mar 02 '16 at 21:59