Help with copy files from multiple directories one inside other of the same type to one directory

Alexander Skwar listen at alexander.skwar.name
Sat Jul 29 13:55:58 UTC 2006


ยท Todd Slater <dontodd at gmail.com>:

> for deb in `find /top/level/directory -type f -iname '*.deb'`

*EXTREMELY* bad. What do you do, when there are file- and/or directory
names with spaces?

As a short hint, *NEVER* *EVER* use "for" and "find" in combination(*).
If you want to loop, use while!

find /top/level/directory -type f -iname '*.deb' | while read deb; do .... done

Alexander Skwar

(*) Okay, there may be ultra rare cases, where for and find might
make sense. Can't think of any, but there maybe.
-- 
Erst kommt das Fressen, dann kommt die Moral.
                -- Berthold Brecht (Dreigroschenoper)






More information about the ubuntu-users mailing list