Re: [SLUG] Q: Fileglobbing with whitespace escaping (in bash, zsh, or any other shell you prefer)?

From: Ian C. Blenke (icblenke@nks.net)
Date: Thu Apr 25 2002 - 12:48:32 EDT


Because `find -type d` expands as a set of arguments that are space
delimited (and "for" expects such a list), any filenames with spaces in
them won't survive. You probably want to do something like:

        $ find . -name '*.wav' -exec bladeenc -br 160 -prio=normal {} \;

or
        $ find . -name '*.wav' | xargs -i@ -l10 bladenc -br 160 -prio=normal @

The "-l10" limits xargs to run bladeenc with 10 filenames at a time.
The '-i@' means put the list of files wherever there is an @.

Yeah, I prefer xargs.

- Ian

On Thu, 2002-04-25 at 09:20, Ben Ostrowsky wrote:
> What am I doing wrong here? The subdirectories of the context in which
> it's executed have spaces in their names, and bash is trying to cd to
> each word in the directory's name separately, so I get something like:
>
> No such directory 'Attack'
> No such directory 'of'
> No such directory 'the'
> No such directory 'Clones'
>
> Here's my code:
>
> #!/bin/bash
> for i in `find -type d`; do {
> cd \"$i\" ;
> echo Changing directory to \"$i\" ;
> ls -al ;
> # bladeenc -br 160 -prio=normal *wav ;
> cd .. ;
> }
> done;
>
> Anyone know how to fix it, or some other way to recurse through
> subdirectories and bladeenc all the WAV files?
>
> Ben



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:38:20 EDT