LWN.net Logo

Useless use of ...

Useless use of ...

Posted Jul 20, 2003 22:17 UTC (Sun) by mikal (guest, #8473)
In reply to: Useless use of ... by sholden
Parent article: Graphics tricks from the Linux command line (IBM developerWorks)

Given it's not an article on shell scripting, does that really matter? Sure,

    find . -type f -name "*.jpg" -exec blah {} \;
    
Is more correct, but it's a lot harder for a newbie to read. I am also sure that the photographic composition of the examples in the article isn't perfect, but it's not an article about how to take a photo, and that is therefore not relevant either.


(Log in to post comments)

Useless use of ...

Posted Jul 21, 2003 1:27 UTC (Mon) by orabidoo (guest, #6639) [Link]

Nah, you just do:

for i in *.jpg; do; whateveryouwant; done

No need for ls or find. Long live shell globbing :)

Speaking of useless elements ...

Posted Jul 21, 2003 13:42 UTC (Mon) by Peter (guest, #1127) [Link]

for i in *.jpg; do; whateveryouwant; done

Eh, be careful when pointing out eye motes. One of those semicolons doesn't belong. (Which semicolon? An exercise for the reader.)

Speaking of useless elements ...

Posted Jul 21, 2003 18:05 UTC (Mon) by flewellyn (subscriber, #5047) [Link]

Obviously, the one after the do. That won't do anything. It should just be: for i in *.jpg; do whateveryouwant; done Then all shall be happy and fluffy and wonderful.

Useless use of find -exec...

Posted Jul 22, 2003 11:38 UTC (Tue) by Dom2 (guest, #458) [Link]

find . -type f -name "*.jpg" -exec blah {} \;

That's not more correct; you should be using xargs(1). :-)

find . -name '*.jpg' | xargs blah

The usual caveat about filenames with spaces in them requiring this instead:

find . -name '*.jpg' -print0 | xargs -0 blah

-Dom

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds