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

From: Ronan Heffernan (ronan.heffernan@shawus.com)
Date: Thu Apr 25 2002 - 10:00:18 EDT


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

You could use something more complex (ie a Python script) to re-write
your filenames (and use dirwalk() to execute a command against every
matching item). Or maybe you could use the -exec option on find:

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

--ronan



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