Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

false

    $ ls -Ql
    totale 4
    -rw-r--r-- 1 zed users 33 set  6 07:30 "    spaces    "
    $
    $ find -name '*spaces*' | while read text; do
        cat "$text";
    done
    cat: ./    spaces: File o directory non esistente
    $
    $ find -name '*spaces*' -print0 | xargs -0 cat
    while read is broken with spaces
    $


IFS needs some care and attention and read should have -r.

    $ ls -Q
    "   spaces   "
    $ ls | while IFS="\n" read -r f; do ls "$f"; done
       spaces   
    $
For lots of grim detail see David A. Wheeler's http://www.dwheeler.com/essays/fixing-unix-linux-filenames.h...


That is a good point, but it is a much more degenerate case than the more common internal space.


Only for file names starting or ending with spaces, as far as I can tell, which are pretty unusual.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: