Spaces Between Words in Files
David Elliott
dce at smsc.sony.com
Sat Nov 17 15:59:59 AEST 1990
In article <1990Nov16.200510.22830 at cbnewsk.att.com> abar at 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.)
More information about the Comp.unix.questions
mailing list