Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: somehow offtopic: looping filenames
- X-seq: zsh-users 16774
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: somehow offtopic: looping filenames
- Date: Mon, 20 Feb 2012 19:38:10 +0100
- In-reply-to: <20120220181650.GA11514@solfire> (meino cramer's message of "Mon, 20 Feb 2012 19:16:50 +0100")
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20120220181650.GA11514@solfire>
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