Bash: for…in-loop fails, what am I doing wrong?
Tony Arnold
tony.arnold at manchester.ac.uk
Thu Jan 10 21:30:50 UTC 2013
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.
>
--
Tony Arnold, Tel: +44 (0) 161 275 6093
Head of IT Security, Fax: +44 (0) 705 344 3082
University of Manchester, Mob: +44 (0) 773 330 0039
Manchester M13 9PL. Email: tony.arnold at manchester.ac.uk
More information about the ubuntu-users
mailing list