Re: How to use cd with special chars in a network directory name?
- From: Robert Heller <heller@xxxxxxxxxxxx>
- Date: Thu, 16 Mar 2006 01:02:19 +0100
"Jeff" <milleratotago@xxxxxxxxx>,
In a message on 15 Mar 2006 15:02:18 -0800, wrote :
"> (Sorry if this is a dumb question--I'm a bit of a Linux newbie.)
">
"> I need to access some files on a Novell server from
"> a (debian) Linux machine. I mount the server with a
"> command like this:
"> mount -t smbfs username=myname ServerMountPointName LocalDir
"> and then I can cd into LocalDir and ls the files and subdirs just fine.
">
"> The problem is that the directory structure on the server has some
"> directories whose names start with the minus sign, like "-main",
"> and I cannot get Linux to cd into those directories. From reading
"> various docs and faqs on the internet, I thought that one of these
"> should work, but none do:
"> cd -main
"> cd '-main'
"> cd `-main'
"> cd `-main`
"> cd "-main"
Did you try:
cd ./-main
Filenames that start with a dash (-) can be 'escaped' by prefixing the
name with the directory path. The directory path './' can always be
put in front of a 'troublesome' filename.
The reason the various quoting forms don't work is because they don't
really do anything about the minus sign -- quoting in and of itself is
mostly for dealing with characters the *shell* considers special (like
spaces or question marks and whatnot).
"> (In all cases, the Linux complaint suggests to me that it thinks
"> -main is some kind of cd option switch.)
">
"> I guess it isn't _just_ a network-related problem, because even on
"> the local drive I am also unable to make a new directory called
"> "-main" with any version of a command like:
"> mkdir -main
"> mkdir `-main'
"> etc
">
"> Any suggestions other than renaming all of the directories
"> on the server?
Some commands support the use of '--' as a way if saying that there are
no more options on the command line, even if something that *looks*
like an option follows. But putting a directory path in front of a
filename always works. A directory *path* cannot start with a minus
sign. It either starts with a slash (/), and is an *absolute* path or
it starts with a dot (.), and is a *relative* path (to the current
working directory). './' is the directory that is the relative path to
the current working directory from the current working directory. Once
you start with a relative or absolute directory path, any *embedded*
path elements that start with a minus sign are just path elements and
won't be seen as command options.
">
"> Thank you.
">
">
Robert Heller -- 978-544-6933
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller@xxxxxxxxxxxx -- Contract Programming: C/C++, Tcl/Tk
.
- References:
- Prev by Date: Re: How to use cd with special chars in a network directory name?
- Next by Date: Default resource limits setrlimit()
- Previous by thread: Re: How to use cd with special chars in a network directory name?
- Next by thread: Default resource limits setrlimit()
- Index(es):
Relevant Pages
|