Running a command on all file occurences in a directory tree

Chris F.A. Johnson c.f.a.johnson-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Fri Oct 8 23:24:10 UTC 2004


On Fri, 8 Oct 2004, Fraser Campbell wrote:

> On Friday 08 October 2004 18:48, Chris F.A. Johnson wrote:
>
>>       So long as there are no filenames containing newlines:
>>
>> find . -type f -name "*,jpg" |
>>   while IFS= read -r FILENAME
>>   do
>>      convert "$FILENAME" -resize 425 "$FILENAME"
>>   done
>
> Why not just:
>
>    find . -type f -name \*.jpg | while read file; do
>        convert "$file" -resize 425 "small-$file"
>    done
>
> My question I guess is what's the difference between
> "while IFS= read -r file" and "while read file"?

    Compare:

fn="  qwe\x x.jpg"
printf "%s\n" "$fn" | { IFS= read -r x; printf ":%s:\n" "$x"; }
printf "%s\n" "$fn" | { read -r x; printf ":%s:\n" "$x"; }
printf "%s\n" "$fn" | { read x; printf ":%s:\n" "$x"; }


> Also I'd think input and output files should be different on the conver
> command, though I'm not sure what op wanted.

    Agreed.

-- 
 	Chris F.A. Johnson                      http://cfaj.freeshell.org
 	=================================================================
                 Everything in moderation -- including moderation


More information about the Legacy mailing list