Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: somehow offtopic: looping filenames



meino.cramer@xxxxxx wrote:
> I habe a loop like this:
>
> for fn *
> do
>     flac $fn
> done
>
> Unfortunately, some file have 'illegal' filenames like
>
>     20120220-_-19db.wav
> or
>     20120220 sensor10 up.wav
>
>
> which parts flac sees as unknown commmand options or as
> two file and the loop fails.

So, you're setting `sh_word_split'? Or are you using another shell?

This should work in every shell:

  for i in ./*; do
      flac "$i"
  done

The ./ makes sure the file name cannot start in a dash, which many
applications would otherwise take as an option name. The "$i" makes sure
the shell sees the variable contents as one word. Zsh does that with
unquoted parameters by default. You'll have to set the `sh_word_split'
option to get a more bourne-shell-like behaviour.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



Messages sorted by: Reverse Date, Date, Thread, Author