Problem with a simple script
I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:
PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp {} $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi
But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente
. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB
.
Do I have to put anything before find
? It seems that the problem is in find
.
scripting aix
add a comment |
I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:
PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp {} $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi
But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente
. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB
.
Do I have to put anything before find
? It seems that the problem is in find
.
scripting aix
do you mind editing your post to format the code correctly? Simply highlight it, then press the '{}' button in the text box. Thanks
– user5359531
Jan 12 '17 at 17:55
6
$PATH
is a default environment variable which tells your system where to find its program binaries (like thefind
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's$PATH
, and now your system cannot find thefind
program. Try this and see if it works.
– user5359531
Jan 12 '17 at 18:00
also if you want to test this and see what I mean, simply open a new terminal and runecho $PATH
.
– user5359531
Jan 12 '17 at 18:01
1
Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?
– fedeemp
Jan 12 '17 at 18:06
add a comment |
I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:
PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp {} $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi
But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente
. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB
.
Do I have to put anything before find
? It seems that the problem is in find
.
scripting aix
I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:
PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp {} $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi
But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente
. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB
.
Do I have to put anything before find
? It seems that the problem is in find
.
scripting aix
scripting aix
edited 3 hours ago
Rui F Ribeiro
41.5k1483140
41.5k1483140
asked Jan 12 '17 at 17:54
fedeempfedeemp
173
173
do you mind editing your post to format the code correctly? Simply highlight it, then press the '{}' button in the text box. Thanks
– user5359531
Jan 12 '17 at 17:55
6
$PATH
is a default environment variable which tells your system where to find its program binaries (like thefind
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's$PATH
, and now your system cannot find thefind
program. Try this and see if it works.
– user5359531
Jan 12 '17 at 18:00
also if you want to test this and see what I mean, simply open a new terminal and runecho $PATH
.
– user5359531
Jan 12 '17 at 18:01
1
Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?
– fedeemp
Jan 12 '17 at 18:06
add a comment |
do you mind editing your post to format the code correctly? Simply highlight it, then press the '{}' button in the text box. Thanks
– user5359531
Jan 12 '17 at 17:55
6
$PATH
is a default environment variable which tells your system where to find its program binaries (like thefind
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's$PATH
, and now your system cannot find thefind
program. Try this and see if it works.
– user5359531
Jan 12 '17 at 18:00
also if you want to test this and see what I mean, simply open a new terminal and runecho $PATH
.
– user5359531
Jan 12 '17 at 18:01
1
Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?
– fedeemp
Jan 12 '17 at 18:06
do you mind editing your post to format the code correctly? Simply highlight it, then press the '{}' button in the text box. Thanks
– user5359531
Jan 12 '17 at 17:55
do you mind editing your post to format the code correctly? Simply highlight it, then press the '{}' button in the text box. Thanks
– user5359531
Jan 12 '17 at 17:55
6
6
$PATH
is a default environment variable which tells your system where to find its program binaries (like the find
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH
, and now your system cannot find the find
program. Try this and see if it works.– user5359531
Jan 12 '17 at 18:00
$PATH
is a default environment variable which tells your system where to find its program binaries (like the find
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH
, and now your system cannot find the find
program. Try this and see if it works.– user5359531
Jan 12 '17 at 18:00
also if you want to test this and see what I mean, simply open a new terminal and run
echo $PATH
.– user5359531
Jan 12 '17 at 18:01
also if you want to test this and see what I mean, simply open a new terminal and run
echo $PATH
.– user5359531
Jan 12 '17 at 18:01
1
1
Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?
– fedeemp
Jan 12 '17 at 18:06
Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?
– fedeemp
Jan 12 '17 at 18:06
add a comment |
2 Answers
2
active
oldest
votes
$PATH
is a default environment variable which tells your system where to find its program binaries (like the find
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH
, and now your system cannot find the find
program. Try this and see if it works.
add a comment |
PATH
happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find
or cp
.
It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.
In this case, you could use source_dir
and target_dir
, for example, which have the additional benefit of providing the reader with a bit of documentation.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f336938%2fproblem-with-a-simple-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$PATH
is a default environment variable which tells your system where to find its program binaries (like the find
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH
, and now your system cannot find the find
program. Try this and see if it works.
add a comment |
$PATH
is a default environment variable which tells your system where to find its program binaries (like the find
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH
, and now your system cannot find the find
program. Try this and see if it works.
add a comment |
$PATH
is a default environment variable which tells your system where to find its program binaries (like the find
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH
, and now your system cannot find the find
program. Try this and see if it works.
$PATH
is a default environment variable which tells your system where to find its program binaries (like the find
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH
, and now your system cannot find the find
program. Try this and see if it works.
answered Jan 12 '17 at 18:20
user5359531user5359531
1927
1927
add a comment |
add a comment |
PATH
happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find
or cp
.
It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.
In this case, you could use source_dir
and target_dir
, for example, which have the additional benefit of providing the reader with a bit of documentation.
add a comment |
PATH
happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find
or cp
.
It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.
In this case, you could use source_dir
and target_dir
, for example, which have the additional benefit of providing the reader with a bit of documentation.
add a comment |
PATH
happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find
or cp
.
It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.
In this case, you could use source_dir
and target_dir
, for example, which have the additional benefit of providing the reader with a bit of documentation.
PATH
happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find
or cp
.
It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.
In this case, you could use source_dir
and target_dir
, for example, which have the additional benefit of providing the reader with a bit of documentation.
answered Jan 12 '17 at 18:17
KusalanandaKusalananda
136k17256424
136k17256424
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f336938%2fproblem-with-a-simple-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
do you mind editing your post to format the code correctly? Simply highlight it, then press the '{}' button in the text box. Thanks
– user5359531
Jan 12 '17 at 17:55
6
$PATH
is a default environment variable which tells your system where to find its program binaries (like thefind
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's$PATH
, and now your system cannot find thefind
program. Try this and see if it works.– user5359531
Jan 12 '17 at 18:00
also if you want to test this and see what I mean, simply open a new terminal and run
echo $PATH
.– user5359531
Jan 12 '17 at 18:01
1
Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?
– fedeemp
Jan 12 '17 at 18:06