OT: bash help

Garry T. Williams gtwilliams at gmail.com
Sun Jul 7 21:51:05 UTC 2013


On 7-7-13 11:29:05 Mike Wright wrote:
> I'm trying to write a bash command to transcode some videos into audios 
> but am having trouble with filenames that contain spaces.
> 
> ls *flv
> 
> returns this:
> 
> Jorge Drexler - Al otro Lado del Río.flv
> 
> But in a bash for loop it doesn't work.
> 
> for f in `ls *flv`; do echo $f; done
> 
> returns this:
> 
> Jorge
> Drexler
> -
> Al
> otro
> Lado
> del
> Río.flv

Use another shell?

zsh does this:

    garry at vfr$ touch foo\ bar
    garry at vfr$ for f in `ls foo*`;do echo $f;done
    foo bar
    garry at vfr$

In contrast, bash does:

    garry at vfr$ bash
    %n@%m$ for f in `ls foo*`;do echo $f;done
    foo
    bar
    %n@%m$ exit

On 7-7-13 20:38:30 Ian Malone wrote:
> As you've discovered, spaces in machineable filenames aren't great.
> However for this case you may want to consider:
> for F in *flv ; do echo "$F" ; done

This is probably the best solution offered, though.

-- 
Garry T. Williams



More information about the users mailing list