Mail Archives: djgpp/1996/11/26/09:23:30
Errors-To: postmaster AT bloomberg DOT com
X-Authentication-Warning: xsc02.gl.umbc.edu: pjenki1 owned process doing -bs
Date: Mon, 25 Nov 1996 21:06:34 -0500 (EST)
From: Patrick <pjenki1 AT gl DOT umbc DOT edu>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Content-Length: 848
Suppose I want to change dirs to \Program Files. Unix (afaik) doesn't
allow spaces. Is there any way around this? I tried:
1. putting the " the microsoft has you put
2. "dir" and 'd' print out backslashes after every word in a long filename
(w/ spaces). On a guess, I tried changing dirs with one of the seperated
(by a backslash) words. THis works about 50% of the time.
Hmmm. Anybody know?
Actually UNIX and UNIX shells, like bash, don't really care whether you have
spaces in your file and directory names or not. It is just that spaces
separate tokens. In bash you can:
cd Program\ Files
OR
cd 'Program Files'
There are some situations, like when you are passing the directory name to a
script, that the backslash or quotes will be stripped by bash before passing
the directory name on as a single argument token but when the positional
parameter ($1 etc) is used again in the script it will be interpreted as two
tokens. Just quote it again (double quotes permit parameter and variable
expansion). This might explain why backslash quoting 'sometimes' works.
Example:
mycompile Program\ Files fred.c
############### begin mycompile #######################
srcdir="$1"
exec=$2
src=${exec}.c
cd "$srcdir"
gcc -o $exec $src
############## end mycompile ####################
--
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com
A proverb is no proverb to you 'till life has illustrated it. -- John Keats
- Raw text -