Linux Newbie help
 help / color / mirror / Atom feed
From: "Paul Kraus" <pkraus@pelsupply.com>
To: linux-newbie@jimmo.com, linux-newbie@vger.kernel.org
Subject: RE: Variable Quoting
Date: Mon, 14 Oct 2002 15:53:20 -0400	[thread overview]
Message-ID: <005201c273bb$594e0880$64fea8c0@pkrausxp> (raw)
In-Reply-To: <200210142158.20963.linux-newbie@jimmo.com>

Ok I lied. I understand why its not working but how should I workaround
it?
Do I have to have my script gather a list of the files and the pass it
the variable?
That sucks that I can not use a wildcard to just get all.

I have made these changes. Which I though would fix my problem.
string="My Documents/"
cp "${string}*" Which I thought would eliminate the problem. I guess I
am not understanding.


-----Original Message-----
From: linux-newbie-owner@vger.kernel.org
[mailto:linux-newbie-owner@vger.kernel.org] On Behalf Of James Mohr
Sent: Monday, October 14, 2002 3:58 PM
To: linux-newbie@vger.kernel.org
Subject: Re: Variable Quoting



On Monday 14 October 2002 20:38, Paul Kraus wrote:
<SNIP>
> Now with this change
> string="My Documents/*"
> cp "$string" /tmp
>
> cp: cannot stat 'My Documents/*':no such file or directory

Sure because the token that is passed to the cp command includes the
asterisk, 
it doesn't know that it should expand the asterisk (*) to the file
names, so 
it looks for a file with the literal name '*'. 

> So then I for kicks I tried.
>
> cp "My Documents/*" /tmp
> Produces the same error.

Same thing.

>
> So just to make sure that it was not a typo in path I tried. cp My\ 
> Documents/* /tmp
>
> And this worked.

Makes sense as the shell is now expanding the asterisks to the names of
the 
files. You don't see this because it is expanded internally. Create a
shell 
script that just does this copy and put "set -x" on the first list. This

should show you the expanded form before it is passed to cp.

> So is the problem with cp? Since the same syntax seems to work with 
> all other apps? Is cp not capable of taking a double quoted path with 
> spaces?

No, it is the fact that cp does not know to expand the asterisk. Plus
you are 
passing different things to the cp depending on what sets of quotes you
use.

> Redhat 7.3 in case it helps.
Actually the Linux distriubtion is pretty irrelevant in this case. In
fact the 
behavior would be the same on most any *NIX system, as it is standard
shell 
stuff. 

See if these explain more of the details for you:

http://www.linux-tutorial.info/cgi-bin/display.pl?20&0&0&0&3
http://www.linux-tutorial.info/cgi-bin/display.pl?22&0&0&0&3

regards,

jimmo

-- 
---------------------------------------
"Be more concerned with your character than with your reputation. Your
character is what you really are while your reputation is merely what
others think you are." -- John Wooden
---------------------------------------
Be sure to visit the Linux Tutorial:  http://www.linux-tutorial.info
---------------------------------------
NOTE: All messages sent to me in response to my posts to newsgroups or
forums 
are subject to reposting.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie"
in the body of a message to majordomo@vger.kernel.org More majordomo
info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

  reply	other threads:[~2002-10-14 19:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200210142055.11942.linux-newbie@jimmo.com>
2002-10-14 18:38 ` Variable Quoting Paul Kraus
2002-10-14 19:58   ` James Mohr
2002-10-14 19:53     ` Paul Kraus [this message]
2002-10-15 16:13       ` Paul Furness
2002-10-16  7:23         ` ichi
2002-10-16 10:51           ` Paul Furness
2002-10-14 19:55     ` Paul Kraus
2002-10-14 21:00       ` James Mohr
2002-10-14 16:02 Paul Kraus
2002-10-14 16:32 ` Jim Reimer
2002-10-14 16:38   ` Jim Reimer
2002-10-14 17:59     ` Paul Kraus
2002-10-14 20:54 ` Don Petrowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='005201c273bb$594e0880$64fea8c0@pkrausxp' \
    --to=pkraus@pelsupply.com \
    --cc=linux-newbie@jimmo.com \
    --cc=linux-newbie@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox