[TriLUG] RE with bash

Aaron S. Joyner aaron at joyner.ws
Wed Oct 25 00:58:24 EDT 2006


Joseph Mack NA3T wrote:

> On Mon, 23 Oct 2006, Joseph Mack NA3T wrote:
>
> the answer is trivial (RTFM, Q14)
>
> http://home.comcast.net/~j.p.h/cus-faq-2.html#14
>
>> echo "directories=$directories"
>>
>>    gives
>>
>> directories=A|Flash\ Player|foo
>
>
> don't go putting '\' in a filename. Instead stop the shell from doing 
> filename expansion
>
> # directories=A|Flash Player|foo
>
> # set -f; IFS="|"; for directory in $directories; do echo $directory; 
> cd $directory; cd -; done
>
> cd's just fine to Flash Player
>
> Joe
>
But it doesn't handle 'Flash|Player' as a directory name.  I don't have 
to think through the general solution, but reading this made me want to 
point out that you're just trading off the space character as a 
potential problem for the pipe character.  Generally, that's probably a 
pretty good trade, and you could make more esoteric trade offs, (think 
of using ^ or ; instead of |, which seem marginally less likely to 
appear in filenames), but it's important to be aware that you're not 
solving the root problem, you're just conveniently avoiding it.

Aaron S. Joyner



More information about the TriLUG mailing list