Re: Bash: for…in-loop fails, what am I doing wrong?
Johnny Rosenberg
gurus.knugum at gmail.com
Thu Jan 10 22:21:12 UTC 2013
2013/1/10 Tony Arnold <tony.arnold at manchester.ac.uk>:
> Oops! Should read all the way to the end of your post. Sorry.
>
> Tony.
>
> On 10/01/13 21:03, Paul Smith wrote:
>> On Thu, 2013-01-10 at 20:49 +0000, Tony Arnold wrote:
>>> Or you could use the -exec option to the find command as follows:
>>>
>>> find -regextype posix-extended \
>>> -regex '.*/P[A-Z0-9][0-9]{6}\.(jpg|JPG|jpeg)' \
>>> -exec date --reference="{}" '+%Y%m' \;
>>
>> Unfortunately this doesn't address the rest of the OP's loop, which was:
>>
>>> # More things to happen here, but this is only a test.
>>
>> -exec can only invoke a single command hence cannot replace the OP's
>> loop, by itself.
>>
>>> What follows -exec is executed once for each file found. The {} is
>>> replaced with the file name. Note the command must be terminated by an
>>> escaped semi-colon, i.e., \;
>>
>> If you read the rest of my response I did suggest basically the same
>> thing (write a script and invoke it with find -exec).
>>
>> If you have a lot of these kinds of things to do, however, writing
>> scripts to handle each situation can get very annoying.
Thanks for all suggestions and ideas! I am pretty sure it will help me
finish my little script.
Kind regards
Johnny Rosenberg
ジョニー・ローゼンバーグ
More information about the ubuntu-users
mailing list