incava.org

shell programming - loops

Usually, this is good enough for looping through files by name:

for i in `find . -type f -name \*.jar`; do (jar tvf $i | glark --label=$i org.incava.util.Something.class); done

But that does not work with files with spaces in them, because find breaks them apart as separate arguments, such as MP3s automatically named by their artist, album, and titles. So this works instead:

find . -type f -name \*.mp3| while read i; do cp --parents $i /media/MP3Player; done

Valid HTML 4.01!

Valid CSS!