[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Unix-ify File Names



Frank Terbeck wrote:

b) it breaks on filenames with spaces (and other special characters).

    While newlines and other special characters might be rather weird
    for filenames, spaces are perfectly okay and normal in filenames.

    Using 'for i in `ls *`'-type loops breaks this and is one of the
    main reasons why people think spaces are bad in filenames.
    (They are not bad, some people just do not know how to handle
    them properly.)

I usually get by this problem by enclosing the variable in double quotes within the for loop. A basic example:

$> for f in *.jpg; do ls "$f"; done

->HS





Reply to: