Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!wuarchive!zaphod.mps.ohio-state.edu!mips!smsc.sony.com!dce From: dce@smsc.sony.com (David Elliott) Newsgroups: comp.unix.questions Subject: Re: Spaces Between Words in Files Keywords: How and Why? Message-ID: <1990Nov17.045959.392@smsc.sony.com> Date: 17 Nov 90 04:59:59 GMT References: <1990Nov16.200510.22830@cbnewsk.att.com> Distribution: usa Organization: Sony Microsystems Corp, San Jose, CA Lines: 34 In article <1990Nov16.200510.22830@cbnewsk.att.com> abar@cbnewsk.att.com (jerome.t.abar..jr) writes: >The problem is a file that has two words with a space between >them, such as "foo bar". How does a file like this get created, >and how do you read it? The only hard part is getting a shell to pass the name through. Standard shells (derived from sh and csh) allow you to do this by putting quotes around the name. So, I can create a file called "foo bar" by saying vi "foo bar" Single quotes ('') will also work, as will just escaping the space, as in vi foo\ bar >I've found that I can erase the file by using rn f*, but it doesn't >work when I try cat f*. All I can think of is that your version of cat isn't a program, but an incorrectly-written alias, function, or shell script. A correctly-written piece of shell code will always assume the worst about what data the user gives it, and will use some form of quoting. For example: for i in "$@" { process_file "$i" } will work fine no matter what the arguments contain. (Yes, I am assuming a modern shell where "$@" works correctly.)