[TAG] Space in Directory Names

Ben Okopnik ben at linuxgazette.net
Thu Feb 7 16:36:30 MSK 2008


On Thu, Feb 07, 2008 at 12:47:26PM +0530, Amit Kumar Saha wrote:
> On 2/7/08, Ben Okopnik <ben at linuxgazette.net> wrote:
> > On Thu, Feb 07, 2008 at 12:26:20PM +0530, Amit Kumar Saha wrote:
> > > On 2/7/08, Ben Okopnik <ben at linuxgazette.net> wrote:
> > > > On Thu, Feb 07, 2008 at 10:44:23AM +0530, Amit Kumar Saha wrote:
> > > > >
> > > > > Is there any other way other to deal with spaces?
> > > >
> > > > Sure - use Bash completion.
> > >
> > > Yes, but this fails if I have a directory name, such as 'Book'.
> >
> > Really? It works fine for me.
> 
> I have 2 directories - 'Book' and 'Book Reviews'
> 
> $ cd Book
> 
> when I do this and press TAB, I get:
> 
> Book/         Book Reviews/
>
> Now I do this,
> $ cd Book R <TAB> <TAB> <TAB>.....

That's not going to work, because there isn't a 'Book R' string anywhere
in it (there is, however, a '"Book R"' or a 'Book\ R') - so Bash is
going to keep beeping. You could do

``
cd Book\ 
''

where the backslash is followed by a space - or, given that it's Bash,
you could just say

``
cd *s
''

or, from the very start of your 'cd' string,

``
cd /foo/bar/zotz/qux/*s
''

> pressing any number of TABS doesn't show up anything
> 
> Am I missing something?

Yep. You added characters to the string that aren't part of the
filename, as far as Bash is concerned.


-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *




More information about the TAG mailing list