how to copy multiple files to a directory and simultaneously enter in that directory?copying files from...
Is Diceware more secure than a long passphrase?
Can I criticise the more senior developers around me for not writing clean code?
Is the claim "Employers won't employ people with no 'social media presence'" realistic?
How did Captain America manage to do this?
Converting a sprinkler system's 24V AC outputs to 3.3V DC logic inputs
How to display Aura JS Errors Lightning Out
On The Origin of Dissonant Chords
Apply MapThread to all but one variable
What term is being referred to with "reflected-sound-of-underground-spirits"?
Does a large simulator bay have standard public address announcements?
How could Tony Stark make this in Endgame?
Should the Death Curse affect an undead PC in the Tomb of Annihilation adventure?
Checks user level and limit the data before saving it to mongoDB
Philosophical question on logistic regression: why isn't the optimal threshold value trained?
What are the steps to solving this definite integral?
A strange hotel
How much cash can I safely carry into the USA and avoid civil forfeiture?
How to fry ground beef so it is well-browned
Don’t seats that recline flat defeat the purpose of having seatbelts?
Dynamic SOQL query relationship with field visibility for Users
Can SQL Server create collisions in system generated constraint names?
Why does Mind Blank stop the Feeblemind spell?
Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?
Which big number is bigger?
how to copy multiple files to a directory and simultaneously enter in that directory?
copying files from multiple directory to another multiple directoryCopy problem in Ubuntu 14.04 LTSProblem with copying “/home/phablet/” from ubuntu phone to Linux PCHow do I find and copy an arbitrary list of files in terminal?How to copy set of files and folder structure with identical names but different file extensionsThere are some unwanted folders out of nowhere when copying, is this a bug?how to copy a file to the desktopNature of Permissions - Copy Fails on my Own FilesHow do I copy only files that overwrite others in a directoryI want to copy all pdf files into another directory
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am trying to write a bash function in my .bashrc which copy multiple files in a directory and enter it, the problem is that it copies the files but do not enter the directory and says:"omitted directory"
cpcd() if [ -d "${!#}" ]
then
cp "$@" "${!#}" && cd "${!#}" && ls
else
print "last argument is not a directory or does not exist"
fi
copy
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I am trying to write a bash function in my .bashrc which copy multiple files in a directory and enter it, the problem is that it copies the files but do not enter the directory and says:"omitted directory"
cpcd() if [ -d "${!#}" ]
then
cp "$@" "${!#}" && cd "${!#}" && ls
else
print "last argument is not a directory or does not exist"
fi
copy
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Please format the code using the code icon { } above the edit question window.
– user68186
16 hours ago
add a comment |
I am trying to write a bash function in my .bashrc which copy multiple files in a directory and enter it, the problem is that it copies the files but do not enter the directory and says:"omitted directory"
cpcd() if [ -d "${!#}" ]
then
cp "$@" "${!#}" && cd "${!#}" && ls
else
print "last argument is not a directory or does not exist"
fi
copy
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I am trying to write a bash function in my .bashrc which copy multiple files in a directory and enter it, the problem is that it copies the files but do not enter the directory and says:"omitted directory"
cpcd() if [ -d "${!#}" ]
then
cp "$@" "${!#}" && cd "${!#}" && ls
else
print "last argument is not a directory or does not exist"
fi
copy
copy
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 16 hours ago
Davide Luise
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 16 hours ago
Davide LuiseDavide Luise
183
183
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Davide Luise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Please format the code using the code icon { } above the edit question window.
– user68186
16 hours ago
add a comment |
2
Please format the code using the code icon { } above the edit question window.
– user68186
16 hours ago
2
2
Please format the code using the code icon { } above the edit question window.
– user68186
16 hours ago
Please format the code using the code icon { } above the edit question window.
– user68186
16 hours ago
add a comment |
1 Answer
1
active
oldest
votes
When you do this:
cp "$@" "${!#}"
that has the effect that the last argument (the directory name) is repeated.
So, I think what you want is probably this instead (just remove the "${!#}"
):
cp "$@"
The other issue is that you say it does not enter the directory. A script that you just execute normally will not change your current working directory; if you want that to happen you need to source the script instead. So, instead of running it like this:
./yourscript.sh [arguments]
you would then source it, like this:
. yourscript.sh [arguments]
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});
}
});
Davide Luise is a new contributor. Be nice, and check out our Code of Conduct.
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%2faskubuntu.com%2fquestions%2f1138354%2fhow-to-copy-multiple-files-to-a-directory-and-simultaneously-enter-in-that-direc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When you do this:
cp "$@" "${!#}"
that has the effect that the last argument (the directory name) is repeated.
So, I think what you want is probably this instead (just remove the "${!#}"
):
cp "$@"
The other issue is that you say it does not enter the directory. A script that you just execute normally will not change your current working directory; if you want that to happen you need to source the script instead. So, instead of running it like this:
./yourscript.sh [arguments]
you would then source it, like this:
. yourscript.sh [arguments]
add a comment |
When you do this:
cp "$@" "${!#}"
that has the effect that the last argument (the directory name) is repeated.
So, I think what you want is probably this instead (just remove the "${!#}"
):
cp "$@"
The other issue is that you say it does not enter the directory. A script that you just execute normally will not change your current working directory; if you want that to happen you need to source the script instead. So, instead of running it like this:
./yourscript.sh [arguments]
you would then source it, like this:
. yourscript.sh [arguments]
add a comment |
When you do this:
cp "$@" "${!#}"
that has the effect that the last argument (the directory name) is repeated.
So, I think what you want is probably this instead (just remove the "${!#}"
):
cp "$@"
The other issue is that you say it does not enter the directory. A script that you just execute normally will not change your current working directory; if you want that to happen you need to source the script instead. So, instead of running it like this:
./yourscript.sh [arguments]
you would then source it, like this:
. yourscript.sh [arguments]
When you do this:
cp "$@" "${!#}"
that has the effect that the last argument (the directory name) is repeated.
So, I think what you want is probably this instead (just remove the "${!#}"
):
cp "$@"
The other issue is that you say it does not enter the directory. A script that you just execute normally will not change your current working directory; if you want that to happen you need to source the script instead. So, instead of running it like this:
./yourscript.sh [arguments]
you would then source it, like this:
. yourscript.sh [arguments]
answered 15 hours ago
EliasElias
2458
2458
add a comment |
add a comment |
Davide Luise is a new contributor. Be nice, and check out our Code of Conduct.
Davide Luise is a new contributor. Be nice, and check out our Code of Conduct.
Davide Luise is a new contributor. Be nice, and check out our Code of Conduct.
Davide Luise is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1138354%2fhow-to-copy-multiple-files-to-a-directory-and-simultaneously-enter-in-that-direc%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
2
Please format the code using the code icon { } above the edit question window.
– user68186
16 hours ago