find mtime exec still gets too many arguments
I thought the trick when you couldn't do a straight up rm on a large number of files was to do a
find /path/* -mtime +7 -exec rm -rf {} \; but is there a trick for when even that kicks back a too many warning? or do i just need to use it multiple times with a more specific wildcard? |
Hm, really? How many files are you trying to delete? What is the specific text of the error message? I've not encountered such a problem before, but would be curious to see.
Anyway, you could of course split up the problem size. If there's not another more direct solution with find. |
think it's like over 480,000 or so? and i'm getting the too many arguments error.
|
Ah, maybe this, that glob is probably the issue:
Code:
find /path/* -mtime +7 -exec rm -rf {} \ Code:
find /path -mtime +7 | xargs rm |
so no wildcard in that new one you want me to try? won't be able to try it till next week now unfortunately.
|
Right, I think the wildcard is the problem, not the find command itself.
|
That worked! Thanks. But can you explain again why this worked? ;)
|
Unless quoted or escaped, globbing patterns such as "*" are expanded by the shell before the command is executed. So when you ran the above command, the shell was really trying to run this:
Code:
find /path/file1 /path/file2 /path/file3 /path/file4 (...etc) -mtime +7 -exec rm -rf {} \; But note also that find has it's own built-in globbing ability, for use in options like -name. This is separate from the shell's globbing feature, and so these patterns must be quoted so that the shell passes them to the command as-is. e.g.: Code:
find /path -type f -name "*.txt" -print |
Ah, so that's why find was choking, it expands it right there. and now i know what a glob is too. thanks.
|
All times are GMT -5. The time now is 01:46 AM. |