* Question
Will Martin -- AMXAL-RI
wmartin at almsa-1.arpa
Wed Nov 30 07:22:53 AEST 1988
I have a query about filename generation/wildcard expansion. I have looked
in the man pages and in several UNIX books, and talked about this locally,
but haven't found an explanation. I've tested it on both Sys V (on a Sperry
Unisys) and 4.3 BSD (on a VAX 750). It seems to be a consistent difference
between sh and csh.
Given the situation where you are trying to redirect output to a directory
in some path structure, where you do have write access, but want to save
time in typing:
Say my login directory is /usr/wm. I also own a directory in another filesystem:
"/data/save-backups". I am sitting in /usr/wm and want to put some data into
that other directory, but want to avoid typing out "save-backups" all the time.
There is nothing else under /data that begins with "sa".
So I do this:
cat foo > /data/sa*/bar or cat foo >> /data/sa*/bar
Under "sh", no matter whether or not "bar" exists in that destination
directory, this won't work. I get the response:
sh: /data/sa*/bar: cannot create
The shell will not expand that "*" to fill out the directory name. I have to
type out the full "/data/save-backups/bar" pathname to get it to work.
Under "csh", if "bar" doesn't exist, I get: "/data/sa*/bar: No match",
but, if "bar" DOES exist, and I do either:
cat foo > /data/sa*/bar or cat foo >> /data/sa*/bar
it will work OK! So "csh" expands the wildcard * correctly in this case.
My query: Is this just a case where "sh" was broken and "csh" fixed it?
Or is there something else going on here? And, if "csh" lets this work
as shown, why does it NOT work when creating the file initially?
What I don't understand is why the expansion doesn't work under "sh".
You are sitting at the shell at this point. If the command was an "ls",
the "*" WOULD expand OK. Why doesn't it expand in this case?
Puzzled,
Will Martin
"wmartin at almsa-1.arpa"
More information about the Comp.unix.questions
mailing list