Path: utzoo!attcan!uunet!vsedev!logan From: logan@vsedev.VSE.COM (James Logan III) Newsgroups: comp.unix.questions Subject: Re: * Question Message-ID: <1261@vsedev.VSE.COM> Date: 30 Nov 88 04:27:29 GMT References: <17661@adm.BRL.MIL> Reply-To: logan@vsedev.VSE.COM (James Logan III) Organization: VSE Software Development Lab Lines: 55 In article <17661@adm.BRL.MIL> wmartin@almsa-1.arpa (Will Martin -- AMXAL-RI) writes: #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. # Every version of the Bourne shell that I have seen does not interpret the filename expansion characters after a redirection symbol. I believe this is to prevent cat foobar >/data/sa*/bar from expanding into cat foobar >/data/sally/bar /data/sandy/bar which would effectively be the same as cat foobar /data/sandy/bar >/data/sally/bar which was probably not intended. The Korn shell gets this right by expanding the wildcard only if one file matches. If more than one file matches, the wildcard is used literally. -Jim -- Jim Logan logan@vsedev.vse.com (703) 892-0002 uucp: ..!uunet!vsedev!logan inet: logan%vsedev.vse.com@uunet.uu.net