[LBo] how do I recursive delete a file based on pattern match?
Andrew Henry
adhenry at bredband.net
Tue Apr 3 20:54:57 CEST 2007
Jim Westbrook wrote:
> Billy Pollifrone wrote:
>
>> Andrew Henry wrote:
>> =
>>
>>> Billy Pollifrone wrote:
>>> =
>>>> find -name "ZbThumbnail.*" -exec rm {} ;
>>>>
>>>> =
>>>> =
>>> Much obliged for the tip Billy, but I still have problems. I
>>> realise that this is probably the right way to do it, but something
>>> is not behaving and I get errors. Do you know what the problem
>>> could be?
>>>
>>> andrew at everest:~/Photos$ find -name "ZbThumbnail.info" -exec rm {} ;
>>> find: missing argument to `-exec'
>>>
>>> =
>>
>> Sounds like the shell is messing with the parameters. Do this:
>>
>> find -name "ZbThumbnail.*" -exec "rm {}" \;
>>
>> I've been attempting the find command (against a different filename
>> string) and having the same "mising argument" error. So, I trind an
>> strace capturing the output. Here's the last few lines:
>> =
>>
>
> open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/findutils.mo",
> O_RDONLY) =3D
> -1 ENOENT (No such file or directory)
> open("/usr/share/locale/en.utf8/LC_MESSAGES/findutils.mo", O_RDONLY) =3D
> -1 ENOENT
> (No such file or directory)
> open("/usr/share/locale-langpack/en/LC_MESSAGES/findutils.mo",
> O_RDONLY) =3D -1 EN
> OENT (No such file or directory)
> open("/usr/share/locale/en/LC_MESSAGES/findutils.mo", O_RDONLY) =3D -1
> ENOENT (No
> such file or directory)
> write(2, "find: ", 6find: ) =3D 6
> write(2, "missing argument to `-exec\'", 27missing argument to
> `-exec') =3D 27
> write(2, "\n", 1
> ) =3D 1
> close(1) =3D 0
> exit_group(1) =3D ?
> Process 7246 detached
>
>
> Please note: all of the "open("<whatever locale file>") fail with a
> "No such..." error although ALL of the files exist in the directories
> specified. ALSO, all of the specified directories and files have
> permissions of 755, so they should be globally readable. I'm
> beginning to think this a real bug within the find command.
>
> JimW
>
Yeah I get the same, but I think it is because I have not specified the
right directory in the rm command...
find: rm ./Marcus & Marie Visit/ZbThumbnail.info: No such file or directory
find: rm ./Kathrines Hen party/ZbThumbnail.info: No such file or directory
find: rm ./Mark and katherines baby/ZbThumbnail.info: No such file or
directory
I am in folder ~/Photos when I run the command but the output above
leads me to believe that rm thinks I should be in each of the
subdirectories for the command to work. Seems like I have to either
'cd' into each directory or somehow specify the full path within the rm
command.
--andrew
-- =
GnuPG Key ID: ECB18ABA
Fingerprint: FDF3 91FC F5BC 1164 E217 315E 337E 219B ECB1 8ABA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://linuxbasics.org/pipermail/qna/attachments/20070403/47d8fe2b/si=
gnature.pgp
More information about the QnA
mailing list