Re: How to use cd with special chars in a network directory name?



"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







.



Relevant Pages

  • Re: Dial-up and Windows Networks
    ... > I have a debian box configured on a network of 4 windows pcs, ... > as a gateway/firewall, proxy server, apache server and dns server. ... > Each of the win pcs connects to the dial-up internet thru the linux ... rsh -l linuxuser linuxbox "command" ...
    (comp.os.linux)
  • Re: Dial-up and Windows Networks
    ... > I have a debian box configured on a network of 4 windows pcs, ... > as a gateway/firewall, proxy server, apache server and dns server. ... > Each of the win pcs connects to the dial-up internet thru the linux ... rsh -l linuxuser linuxbox "command" ...
    (alt.linux)
  • Re: Non-intel benchmarks on Conroe vs AMDs AM2 FX62
    ... The little lost angel schreef: ... mainly command line oriented Linux ... server environment, I picked it to reduce any additional confusion I ...
    (comp.sys.ibm.pc.hardware.chips)
  • Re: Linux 7.0 kde problem
    ... I was using the wrong command. ... Silly mistake. ... I'm new to linux so please forgive any mistakes. ... cannot connect to X server ...
    (alt.os.linux.redhat)
  • Re: what permissions are needed to let a php script call the "svn update" subversion command?
    ... What current working directory is needed to make this work? ... server as root and run "svn update" and then see the files copied from ... the Subversion repository to the working copy on the server. ... If the "svn update" command had run in #3, ...
    (comp.unix.programmer)