How does cp -a work
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am trying to understand linux and working through some tutorials. One states that I can copy files to the current directory by using a cp -a
command with a relative pathname such as
cp -a ../somedir/.
It fails each time I run it. Is the syntax incorrect?
I tried the man page, but it didn't seem to find anything that answers my question.
files copy
New contributor
add a comment |
I am trying to understand linux and working through some tutorials. One states that I can copy files to the current directory by using a cp -a
command with a relative pathname such as
cp -a ../somedir/.
It fails each time I run it. Is the syntax incorrect?
I tried the man page, but it didn't seem to find anything that answers my question.
files copy
New contributor
2
you are missing a blank space between somedir and the last dot. See vidarlo 's answer, it is correct. Upvote it! Accept it!
– Henrique
Apr 15 at 20:29
Also something I wish I had known a whole lot earlier when learning Linux & bash is that you can press tab to get autocomplete; press it twice for suggestions.
– rm-vanda
Apr 15 at 20:42
add a comment |
I am trying to understand linux and working through some tutorials. One states that I can copy files to the current directory by using a cp -a
command with a relative pathname such as
cp -a ../somedir/.
It fails each time I run it. Is the syntax incorrect?
I tried the man page, but it didn't seem to find anything that answers my question.
files copy
New contributor
I am trying to understand linux and working through some tutorials. One states that I can copy files to the current directory by using a cp -a
command with a relative pathname such as
cp -a ../somedir/.
It fails each time I run it. Is the syntax incorrect?
I tried the man page, but it didn't seem to find anything that answers my question.
files copy
files copy
New contributor
New contributor
edited Apr 15 at 20:35
zx485
1,48631315
1,48631315
New contributor
asked Apr 15 at 19:57
NodeNewbNodeNewb
182
182
New contributor
New contributor
2
you are missing a blank space between somedir and the last dot. See vidarlo 's answer, it is correct. Upvote it! Accept it!
– Henrique
Apr 15 at 20:29
Also something I wish I had known a whole lot earlier when learning Linux & bash is that you can press tab to get autocomplete; press it twice for suggestions.
– rm-vanda
Apr 15 at 20:42
add a comment |
2
you are missing a blank space between somedir and the last dot. See vidarlo 's answer, it is correct. Upvote it! Accept it!
– Henrique
Apr 15 at 20:29
Also something I wish I had known a whole lot earlier when learning Linux & bash is that you can press tab to get autocomplete; press it twice for suggestions.
– rm-vanda
Apr 15 at 20:42
2
2
you are missing a blank space between somedir and the last dot. See vidarlo 's answer, it is correct. Upvote it! Accept it!
– Henrique
Apr 15 at 20:29
you are missing a blank space between somedir and the last dot. See vidarlo 's answer, it is correct. Upvote it! Accept it!
– Henrique
Apr 15 at 20:29
Also something I wish I had known a whole lot earlier when learning Linux & bash is that you can press tab to get autocomplete; press it twice for suggestions.
– rm-vanda
Apr 15 at 20:42
Also something I wish I had known a whole lot earlier when learning Linux & bash is that you can press tab to get autocomplete; press it twice for suggestions.
– rm-vanda
Apr 15 at 20:42
add a comment |
2 Answers
2
active
oldest
votes
cp -a ../somedir/.
is wrong. The general syntax is
cp source target
You only specified one argument. To copy something to current directory, you can run
cp ../somedir .
Note the space before the dot. .
is shorthand for current directory. ..
is shorthand for parent directory.
+1 but I would have added how-a
maintains last access stamps or something like that :)
– WinEunuuchs2Unix
Apr 15 at 22:55
-a "preserves" everything and recurses. There is a man page for this.
– mckenzm
Apr 16 at 1:52
add a comment |
You can say:
cp -a ../somedir .
if you want to copy the folder it self with its content
Or you can say
cp -a ../somedir/* .
If you want to copy the content of the folder.
the -a
option will try to clone the same file structure with the same file tree to the new location
New contributor
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
});
}
});
NodeNewb 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%2f1134176%2fhow-does-cp-a-work%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
cp -a ../somedir/.
is wrong. The general syntax is
cp source target
You only specified one argument. To copy something to current directory, you can run
cp ../somedir .
Note the space before the dot. .
is shorthand for current directory. ..
is shorthand for parent directory.
+1 but I would have added how-a
maintains last access stamps or something like that :)
– WinEunuuchs2Unix
Apr 15 at 22:55
-a "preserves" everything and recurses. There is a man page for this.
– mckenzm
Apr 16 at 1:52
add a comment |
cp -a ../somedir/.
is wrong. The general syntax is
cp source target
You only specified one argument. To copy something to current directory, you can run
cp ../somedir .
Note the space before the dot. .
is shorthand for current directory. ..
is shorthand for parent directory.
+1 but I would have added how-a
maintains last access stamps or something like that :)
– WinEunuuchs2Unix
Apr 15 at 22:55
-a "preserves" everything and recurses. There is a man page for this.
– mckenzm
Apr 16 at 1:52
add a comment |
cp -a ../somedir/.
is wrong. The general syntax is
cp source target
You only specified one argument. To copy something to current directory, you can run
cp ../somedir .
Note the space before the dot. .
is shorthand for current directory. ..
is shorthand for parent directory.
cp -a ../somedir/.
is wrong. The general syntax is
cp source target
You only specified one argument. To copy something to current directory, you can run
cp ../somedir .
Note the space before the dot. .
is shorthand for current directory. ..
is shorthand for parent directory.
answered Apr 15 at 20:08
vidarlovidarlo
10.9k52852
10.9k52852
+1 but I would have added how-a
maintains last access stamps or something like that :)
– WinEunuuchs2Unix
Apr 15 at 22:55
-a "preserves" everything and recurses. There is a man page for this.
– mckenzm
Apr 16 at 1:52
add a comment |
+1 but I would have added how-a
maintains last access stamps or something like that :)
– WinEunuuchs2Unix
Apr 15 at 22:55
-a "preserves" everything and recurses. There is a man page for this.
– mckenzm
Apr 16 at 1:52
+1 but I would have added how
-a
maintains last access stamps or something like that :)– WinEunuuchs2Unix
Apr 15 at 22:55
+1 but I would have added how
-a
maintains last access stamps or something like that :)– WinEunuuchs2Unix
Apr 15 at 22:55
-a "preserves" everything and recurses. There is a man page for this.
– mckenzm
Apr 16 at 1:52
-a "preserves" everything and recurses. There is a man page for this.
– mckenzm
Apr 16 at 1:52
add a comment |
You can say:
cp -a ../somedir .
if you want to copy the folder it self with its content
Or you can say
cp -a ../somedir/* .
If you want to copy the content of the folder.
the -a
option will try to clone the same file structure with the same file tree to the new location
New contributor
add a comment |
You can say:
cp -a ../somedir .
if you want to copy the folder it self with its content
Or you can say
cp -a ../somedir/* .
If you want to copy the content of the folder.
the -a
option will try to clone the same file structure with the same file tree to the new location
New contributor
add a comment |
You can say:
cp -a ../somedir .
if you want to copy the folder it self with its content
Or you can say
cp -a ../somedir/* .
If you want to copy the content of the folder.
the -a
option will try to clone the same file structure with the same file tree to the new location
New contributor
You can say:
cp -a ../somedir .
if you want to copy the folder it self with its content
Or you can say
cp -a ../somedir/* .
If you want to copy the content of the folder.
the -a
option will try to clone the same file structure with the same file tree to the new location
New contributor
New contributor
answered Apr 15 at 22:37
sh.alawnehsh.alawneh
1011
1011
New contributor
New contributor
add a comment |
add a comment |
NodeNewb is a new contributor. Be nice, and check out our Code of Conduct.
NodeNewb is a new contributor. Be nice, and check out our Code of Conduct.
NodeNewb is a new contributor. Be nice, and check out our Code of Conduct.
NodeNewb 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%2f1134176%2fhow-does-cp-a-work%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
you are missing a blank space between somedir and the last dot. See vidarlo 's answer, it is correct. Upvote it! Accept it!
– Henrique
Apr 15 at 20:29
Also something I wish I had known a whole lot earlier when learning Linux & bash is that you can press tab to get autocomplete; press it twice for suggestions.
– rm-vanda
Apr 15 at 20:42