find does not work correctly with whitespaces

Denys Vlasenko vda.linux at googlemail.com
Fri Sep 21 15:55:32 UTC 2007


On Friday 21 September 2007 14:43, Lukas Rueegg wrote:
> hi all
> 
> i'm using BusyBox v1.1.0 (2007.09.08-10:26+0000) multi-call binary
> 
> the command find unfortunately seems to handle files with whitespaces  
> in the filename incorrectly as the following example shows:
> 
> onion> ls -la
> drwxrwxrwx    2 root     root         4096 Sep 21 15:39 .
> drwxr-xr-x    9 root     root         4096 Sep 20 14:57 ..
> -rwxrwxrwx    1 lru      users        6148 Sep 21 15:22 .DS_Store
> -rwxrwxrwx    1 lru      users          82 Sep 21 15:22 ._test.html
> -rwxrwxrwx    1 samo     users   840050688 Jun 27 16:18 300 -  
> ForumMasti.com.avi
> -rwxrwxrwx    1 samo     users   679016448 Mar  4  2007 Romance And  
> Cigarettes.avi
> -rwxrwxrwx    1 lru      users       40874 Sep 21 15:22 httpd.conf
> -rwxrwxrwx    1 lru      users         623 Sep 21 15:22 test.html
> onion> find . -exec touch '{}' \;
> onion> ls -la
> -rw-r--r--    1 root     root            0 Sep 21 15:40 -
> drwxrwxrwx    2 root     root         4096 Sep 21 15:40 .
> drwxr-xr-x    9 root     root         4096 Sep 20 14:57 ..
> -rwxrwxrwx    1 lru      users        6148 Sep 21 15:40 .DS_Store
> -rwxrwxrwx    1 lru      users          82 Sep 21 15:40 ._test.html
> -rw-r--r--    1 root     root            0 Sep 21 15:40 300
> -rwxrwxrwx    1 samo     users   840050688 Jun 27 16:18 300 -  
> ForumMasti.com.avi
> -rw-r--r--    1 root     root            0 Sep 21 15:40 And
> -rw-r--r--    1 root     root            0 Sep 21 15:40 Cigarettes.avi
> -rw-r--r--    1 root     root            0 Sep 21 15:40  
> ForumMasti.com.avi
> -rw-r--r--    1 root     root            0 Sep 21 15:40 Romance
> -rwxrwxrwx    1 samo     users   679016448 Mar  4  2007 Romance And  
> Cigarettes.avi
> -rwxrwxrwx    1 lru      users       40874 Sep 21 15:40 httpd.conf
> -rwxrwxrwx    1 lru      users         623 Sep 21 15:40 test.html
> 
> as you see, there are new files created, instead of updating the  
> existing files with whitespaces in the filename ...
> 
> does anybody know a workaround to this problem or is this a bug?

The workaround is to updated your busybox to newer version:

$ mkdir "z z"

$ find . -name 'z*' -exec echo '"{}"' \;
"./networking/zcip.c"
"./networking/zcip.o"
"./scripts/kconfig/zconf.gperf"
"./scripts/kconfig/zconf.tab.c_shipped"
"./scripts/kconfig/zconf.y"
"./scripts/kconfig/zconf.hash.c_shipped"
"./scripts/kconfig/zconf.l"
"./scripts/kconfig/zconf.tab.c"
"./scripts/kconfig/zconf.hash.c"
"./scripts/kconfig/zconf.tab.o"
"./shell/ash_test/zecho.c"
"./include/config/feature/xargs/support/zero"
"./include/config/zcip.h"
"./examples/zcip.script"
"./z z"

$ ./busybox find . -name 'z*' -exec echo '"{}"' \;
"./networking/zcip.c"
"./networking/zcip.o"
"./scripts/kconfig/zconf.gperf"
"./scripts/kconfig/zconf.tab.c_shipped"
"./scripts/kconfig/zconf.y"
"./scripts/kconfig/zconf.hash.c_shipped"
"./scripts/kconfig/zconf.l"
"./scripts/kconfig/zconf.tab.c"
"./scripts/kconfig/zconf.hash.c"
"./scripts/kconfig/zconf.tab.o"
"./shell/ash_test/zecho.c"
"./include/config/feature/xargs/support/zero"
"./include/config/zcip.h"
"./examples/zcip.script"
"./z z"  <=============================================== WORKS!

--
vda



More information about the busybox mailing list