Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to do the following in ksh but keep getting cannot stat message for the cp command:



cp $SMOKE_JMX_LOCATION /var/tmp/tempor

Any ideas? I have tried putting quotes around the various variables but with no luck.

share|improve this question
Note the *.*. I don't know enough of the Korn shell, but in Bash, this would require arrays: SMOKE_JMX_LOCATION=("$JMX_ROOT/Smoke Set"/*.*) followed by cp "${SMOKE_JMX_LOCATION[@]}" /var/tmp/tempor. – janmoesen Oct 27 '11 at 13:18
also exists on stackoverflow – glenn jackman Oct 27 '11 at 14:19
cp "$SMOKE_JMX_LOCATION" /var/tmp/tempor

EDIT: I didn't really notice the wildcards. Yes, quoting them will prevent expansion. Is there any reason you need to put them in a variable? Surely this would work:

cp $JMX_ROOT/"Smoke Set"/*.* /var/tmp/tempor
share|improve this answer
Wouldn't work, thanks anyway – Rory Oct 27 '11 at 13:12
Could you expand on "wouldn't work"? Copy-paste your commands and error messages, please. – janmoesen Oct 27 '11 at 13:16
Couldn't get it to work as is, so changed it to the following.. SMOKE_JMX_LOCATION=$JMX_ROOT/Smoke*/*.* I.e. used a wildcard instread of including the space – Rory Oct 27 '11 at 13:24
@Rory, what he gave you is the correct solution (in the edit part at least), youre doing something else wrong, but we cant help unless you give us your commands and errors as requested. – Patrick Oct 27 '11 at 13:52
SMOKE_JMX_LOCATION="$(echo $JMX_ROOT/"Smoke Set"/*.*)"
cp "$SMOKE_JMX_LOCATION" /var/tmp/tempor
share|improve this answer

You can use an alternate field separator to work around that white space in the directory name.




cp ${SMOKE_JMX_LOCATION}/*.* /var/tmp/tempor

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.