Argument list too long
Hi,
I am creating a cronjob that will delete the 14 days old .jpg files on each below directory 20161010 20161011 20161012 20161013 20161014 20161015 20161016 20161017 20161018 Below is the command i used. I want to list them first before removing but I encounter Argument list too long. find */*.jpg -type f -mtime +14 -exec ls -l {} \; -bash: /bin/find: Argument list too long kindly help. Thanks |
Did you try using a search engine for the error?
https://duckduckgo.com/?q=arguement+...low&t=lm&ia=qa (First Result) https://stackoverflow.com/questions/...mands#11289567 You're also using the find command incorrectly. Like this Code:
find */ -iname '*.jpg' -type f -mtime +14 -exec ls -l {} \; Code:
find */*.jpg -type f -mtime +14 -exec ls -l {} \; Which will fix your original issue as well Code:
-name pattern |
it worked for me
Code:
$find */*.jpg -type f -mtime +14 -exec ls -l {} \; Code:
-rw-rw-r-- 1 userx users 5564552 Aug 12 07:44 wallpaper/1_035.jpg |
Giving find a glob as a directory name is more than a bit iffy. There are valid ways to do that, but I recommend against it.
Just off the top I might do something like this Code:
for foo in 20* ; do Code:
for foo in 20* ; do Code:
for foo in 20* ; do This assumes the behavior of the GNU version of find. |
This works
find */ -iname '*.jpg' -type f -mtime +14 -exec ls -l {} \; Thanks Sefyir |
Quote:
Quote:
|
Quote:
As you see above, mine is only ONE solution, and clearly not the most concise. There is always more than one right way. How you THINK is more interesting than the problem itself. The most natural thing for me is the 'divide and conquer' approach. Adjusting your command line to an invoke less likely to be fooled by unexpected glob expansion is another. They are all valid, and all work to accomplish your goal. PS. The original posts crossed. When I gave my first response, it appeared the ONLY response. I was not responding to any of the other replies, because I had not seen them. I would not have you think that one solution is 'better' than the others, all of them that WORK are 'good' answers. |
plus
just typing this Code:
find / in other words if you type Code:
find / -name *jpg output does not have permissions to read. Code:
nd: ‘/run/runit/supervise.socklog-unix’: Permission denied Code:
/home/userz/Dropbox/wallpaperbackups/mixed/C224.jpg |
Quote:
Yes, there are many ways to solve it. Quote:
Eg. if you run it in a directory that contain foo.jpg, the shell will replace Code:
find / -name *jpg Code:
set -xv Code:
find / -name "*jpg" |
Quote:
or you can just drop that completely then look at what you get using just this. Code:
find / *jpg Code:
userx@Voided.1 & ~ >> $find / \*jpg | wc -l |
@BW-userx, the glob is to be done by the find command, not by the shell. Therefore must be escaped, e.g. with quotes
Code:
find / -name "*jpg" The */ glob lists only directories. Should work with all shells, and is perfectly valid. The only side effect is it remains */ if there is no directory (unless nullglob option is set), but this will give a clear error message in find, not any unwanted action. |
Quote:
|
All times are GMT -5. The time now is 07:37 PM. |