cp -a doesn't work to copy all files inside a directoryHow to copy a folder recursively in an idempotent way...

Checking a beta regression model via glmmTMB with DHARMa package

What's the terminology for this alternative minimization algorithm?

How to prevent cutting edges on my TV, HDMI-connected?

Defense against attacks using dictionaries

Are modern clipless shoes and pedals that much better than toe clips and straps?

How do I request a longer than normal leave of absence period for my wedding?

Does a face-down creature with morph retain its damage when it is turned face up?

Avoiding racist tropes in fantasy

Is using a hyperlink to close a modal a poor design decision?

Prove your innocence

how do you harvest carrots in creative mode

Using `With[...]` with a list specification as a variable

Is a player able to change alignment midway through an adventure?

If the first law of thermodynamics ensures conservation of energy, why does it allow systems to lose energy?

How to respectfully refuse to assist co-workers with IT issues?

If all stars rotate, why was there a theory developed, that requires non-rotating stars?

Is "The life is beautiful" incorrect or just very non-idiomatic?

Are there any elected officials in the U.S. who are not legislators, judges, or constitutional officers?

Can you feel passing through the sound barrier in an F-16?

for loop not working in bash

How to find multiple values on the same line in any permutation using Notepad++?

LeetCode: Pascal's Triangle C#

How is the list of apps allowed to install another apps populated?

Which household object drew this pattern?



cp -a doesn't work to copy all files inside a directory


How to copy a folder recursively in an idempotent way using cp?How to remove all the files in a directory?How can I selectively copy files from one directory to another directory?How to I copy the directory and subfolders but ignore certain files in the subfolder?xfs directory quota doesn't workCopy all files matching criteria on find command with -exec“find” doesn't list all files under specific directoriesHow to copy “just files” recursively






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







-1















I desire to copy all files inside a directory which has only these files (all are regular files - there are no directories, symlinks, etc, inside that directory) to another pre-existing directory.

The files have pretty common names like robots.txt and don't follow any specific pattern.

I tried a similar command:



cp -a "$HOME"/a "$HOME"/b 


I understand that -a is a shortcut-combo for -d (preserving mode, ownership and timestamps) and -R which orders recursive copying;

If copying is recursive, why the files aren't copied and what would be a solution?



In practice there are only 5 files so I could execute similar to cp "$HOME"/a/{file1,file2,file3,file4,file5,...} "$HOME"/b but if all files is more than it will probably be not efficient.










share|improve this question






















  • 1





    Is $HOME/b a pre-existing directory? Did you look inside it?

    – Kusalananda
    2 days ago













  • Yes, it is indeed. Edited.

    – JohnDoea
    yesterday











  • The paragraph “In practice there…cp file1 ... "$HOME"/a "$HOME"/b…” is wrong.

    – ctrl-alt-delor
    yesterday











  • @ctrl-alt-delor hello, what's wrong please?

    – JohnDoea
    yesterday











  • it is not equivalent: try it.

    – ctrl-alt-delor
    yesterday


















-1















I desire to copy all files inside a directory which has only these files (all are regular files - there are no directories, symlinks, etc, inside that directory) to another pre-existing directory.

The files have pretty common names like robots.txt and don't follow any specific pattern.

I tried a similar command:



cp -a "$HOME"/a "$HOME"/b 


I understand that -a is a shortcut-combo for -d (preserving mode, ownership and timestamps) and -R which orders recursive copying;

If copying is recursive, why the files aren't copied and what would be a solution?



In practice there are only 5 files so I could execute similar to cp "$HOME"/a/{file1,file2,file3,file4,file5,...} "$HOME"/b but if all files is more than it will probably be not efficient.










share|improve this question






















  • 1





    Is $HOME/b a pre-existing directory? Did you look inside it?

    – Kusalananda
    2 days ago













  • Yes, it is indeed. Edited.

    – JohnDoea
    yesterday











  • The paragraph “In practice there…cp file1 ... "$HOME"/a "$HOME"/b…” is wrong.

    – ctrl-alt-delor
    yesterday











  • @ctrl-alt-delor hello, what's wrong please?

    – JohnDoea
    yesterday











  • it is not equivalent: try it.

    – ctrl-alt-delor
    yesterday














-1












-1








-1








I desire to copy all files inside a directory which has only these files (all are regular files - there are no directories, symlinks, etc, inside that directory) to another pre-existing directory.

The files have pretty common names like robots.txt and don't follow any specific pattern.

I tried a similar command:



cp -a "$HOME"/a "$HOME"/b 


I understand that -a is a shortcut-combo for -d (preserving mode, ownership and timestamps) and -R which orders recursive copying;

If copying is recursive, why the files aren't copied and what would be a solution?



In practice there are only 5 files so I could execute similar to cp "$HOME"/a/{file1,file2,file3,file4,file5,...} "$HOME"/b but if all files is more than it will probably be not efficient.










share|improve this question
















I desire to copy all files inside a directory which has only these files (all are regular files - there are no directories, symlinks, etc, inside that directory) to another pre-existing directory.

The files have pretty common names like robots.txt and don't follow any specific pattern.

I tried a similar command:



cp -a "$HOME"/a "$HOME"/b 


I understand that -a is a shortcut-combo for -d (preserving mode, ownership and timestamps) and -R which orders recursive copying;

If copying is recursive, why the files aren't copied and what would be a solution?



In practice there are only 5 files so I could execute similar to cp "$HOME"/a/{file1,file2,file3,file4,file5,...} "$HOME"/b but if all files is more than it will probably be not efficient.







directory cp recursive gnu






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 15 hours ago









ctrl-alt-delor

14.2k5 gold badges33 silver badges64 bronze badges




14.2k5 gold badges33 silver badges64 bronze badges










asked 2 days ago









JohnDoeaJohnDoea

721 gold badge11 silver badges48 bronze badges




721 gold badge11 silver badges48 bronze badges











  • 1





    Is $HOME/b a pre-existing directory? Did you look inside it?

    – Kusalananda
    2 days ago













  • Yes, it is indeed. Edited.

    – JohnDoea
    yesterday











  • The paragraph “In practice there…cp file1 ... "$HOME"/a "$HOME"/b…” is wrong.

    – ctrl-alt-delor
    yesterday











  • @ctrl-alt-delor hello, what's wrong please?

    – JohnDoea
    yesterday











  • it is not equivalent: try it.

    – ctrl-alt-delor
    yesterday














  • 1





    Is $HOME/b a pre-existing directory? Did you look inside it?

    – Kusalananda
    2 days ago













  • Yes, it is indeed. Edited.

    – JohnDoea
    yesterday











  • The paragraph “In practice there…cp file1 ... "$HOME"/a "$HOME"/b…” is wrong.

    – ctrl-alt-delor
    yesterday











  • @ctrl-alt-delor hello, what's wrong please?

    – JohnDoea
    yesterday











  • it is not equivalent: try it.

    – ctrl-alt-delor
    yesterday








1




1





Is $HOME/b a pre-existing directory? Did you look inside it?

– Kusalananda
2 days ago







Is $HOME/b a pre-existing directory? Did you look inside it?

– Kusalananda
2 days ago















Yes, it is indeed. Edited.

– JohnDoea
yesterday





Yes, it is indeed. Edited.

– JohnDoea
yesterday













The paragraph “In practice there…cp file1 ... "$HOME"/a "$HOME"/b…” is wrong.

– ctrl-alt-delor
yesterday





The paragraph “In practice there…cp file1 ... "$HOME"/a "$HOME"/b…” is wrong.

– ctrl-alt-delor
yesterday













@ctrl-alt-delor hello, what's wrong please?

– JohnDoea
yesterday





@ctrl-alt-delor hello, what's wrong please?

– JohnDoea
yesterday













it is not equivalent: try it.

– ctrl-alt-delor
yesterday





it is not equivalent: try it.

– ctrl-alt-delor
yesterday










2 Answers
2






active

oldest

votes


















2















Scenarios:





  1. Directory a exists but b doesn't`:



    cp -a "$HOME"/a "$HOME"/b


    will copy the entire directory a to a new directory b




  2. Directories a and b exist:



    cp -a "$HOME"/a "$HOME"/b


    will copy the directory a inside directory b. So you'll get a "$HOME"/b/a directory as a result.




  3. Directories a and b exist:



    cp -a "$HOME"/a/* "$HOME"/b


    will copy the contents of a inside directory b but exclude hidden files and directories. While some shells have some options to include them, here the best approach would be:



    cp -a ~/a/. ~/b/



This is what I understand you want.






share|improve this answer























  • 4





    Note that the very last command would not copy hidden files. This may not be an issue in this particular case, but it may well be an issue in the general case. To solve that, enable globbing of hidden files (in bash: shopt -s dotglob, in zsh: setopt GLOB_DOTS).

    – Kusalananda
    2 days ago








  • 3





    Change the star for a dot in the last command and it'll copy everything in a for you. See this answer for the explanation.

    – roaima
    yesterday













  • So much time passed since I last used shell globs - I forgot I have to use them here... A trouble of being a shell scripting amateur.

    – JohnDoea
    yesterday











  • @Kusalananda, in zsh, you'd rather use cp -a "$HOME"/a/*(D) "$HOME"/b to include hidden files rather than change a global setting. But cp -a ~/a/. ~/b/ would be best.

    – Stéphane Chazelas
    11 hours ago



















0















cp safety tips:



copying a directory



Directories a and b exist:



cp -a a b/
cp -a -t b a


will copy the directory a inside directory b



Directory a exists but b doesn't:



cp -a a b/
cp -a -t b a


will generate a friendly error message



copying a file



Directory b exists



cp -T a b


will generate a friendly error message



Directory b does not exist



cp -T a b
will copy the file, to b





Note not all versions of cp/mv/ln have the -t or -T options, but all allow the / to ensure that the b is a directory. If they don't have these options, then there is no way to guarantee that b is not an existing directory.






share|improve this answer




























  • Not all implementations of cp have the -T option. Furthermore, some implementations require /. instead of just /. For example cp -a a/. b rather than cp -a a/ b. (And all implementations handle it, so there's no harm including the trailing dot on the source directory.)

    – roaima
    yesterday











  • I have already added a note about -T not being in all implementations.

    – ctrl-alt-delor
    16 hours ago











  • Yes... but on that same note, just / on its own also doesn't work everywhere, but /. (with that trailing dot) does.

    – roaima
    15 hours ago











  • @roaima can you edit the answer.

    – ctrl-alt-delor
    12 hours ago














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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536559%2fcp-a-doesnt-work-to-copy-all-files-inside-a-directory%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









2















Scenarios:





  1. Directory a exists but b doesn't`:



    cp -a "$HOME"/a "$HOME"/b


    will copy the entire directory a to a new directory b




  2. Directories a and b exist:



    cp -a "$HOME"/a "$HOME"/b


    will copy the directory a inside directory b. So you'll get a "$HOME"/b/a directory as a result.




  3. Directories a and b exist:



    cp -a "$HOME"/a/* "$HOME"/b


    will copy the contents of a inside directory b but exclude hidden files and directories. While some shells have some options to include them, here the best approach would be:



    cp -a ~/a/. ~/b/



This is what I understand you want.






share|improve this answer























  • 4





    Note that the very last command would not copy hidden files. This may not be an issue in this particular case, but it may well be an issue in the general case. To solve that, enable globbing of hidden files (in bash: shopt -s dotglob, in zsh: setopt GLOB_DOTS).

    – Kusalananda
    2 days ago








  • 3





    Change the star for a dot in the last command and it'll copy everything in a for you. See this answer for the explanation.

    – roaima
    yesterday













  • So much time passed since I last used shell globs - I forgot I have to use them here... A trouble of being a shell scripting amateur.

    – JohnDoea
    yesterday











  • @Kusalananda, in zsh, you'd rather use cp -a "$HOME"/a/*(D) "$HOME"/b to include hidden files rather than change a global setting. But cp -a ~/a/. ~/b/ would be best.

    – Stéphane Chazelas
    11 hours ago
















2















Scenarios:





  1. Directory a exists but b doesn't`:



    cp -a "$HOME"/a "$HOME"/b


    will copy the entire directory a to a new directory b




  2. Directories a and b exist:



    cp -a "$HOME"/a "$HOME"/b


    will copy the directory a inside directory b. So you'll get a "$HOME"/b/a directory as a result.




  3. Directories a and b exist:



    cp -a "$HOME"/a/* "$HOME"/b


    will copy the contents of a inside directory b but exclude hidden files and directories. While some shells have some options to include them, here the best approach would be:



    cp -a ~/a/. ~/b/



This is what I understand you want.






share|improve this answer























  • 4





    Note that the very last command would not copy hidden files. This may not be an issue in this particular case, but it may well be an issue in the general case. To solve that, enable globbing of hidden files (in bash: shopt -s dotglob, in zsh: setopt GLOB_DOTS).

    – Kusalananda
    2 days ago








  • 3





    Change the star for a dot in the last command and it'll copy everything in a for you. See this answer for the explanation.

    – roaima
    yesterday













  • So much time passed since I last used shell globs - I forgot I have to use them here... A trouble of being a shell scripting amateur.

    – JohnDoea
    yesterday











  • @Kusalananda, in zsh, you'd rather use cp -a "$HOME"/a/*(D) "$HOME"/b to include hidden files rather than change a global setting. But cp -a ~/a/. ~/b/ would be best.

    – Stéphane Chazelas
    11 hours ago














2














2










2









Scenarios:





  1. Directory a exists but b doesn't`:



    cp -a "$HOME"/a "$HOME"/b


    will copy the entire directory a to a new directory b




  2. Directories a and b exist:



    cp -a "$HOME"/a "$HOME"/b


    will copy the directory a inside directory b. So you'll get a "$HOME"/b/a directory as a result.




  3. Directories a and b exist:



    cp -a "$HOME"/a/* "$HOME"/b


    will copy the contents of a inside directory b but exclude hidden files and directories. While some shells have some options to include them, here the best approach would be:



    cp -a ~/a/. ~/b/



This is what I understand you want.






share|improve this answer















Scenarios:





  1. Directory a exists but b doesn't`:



    cp -a "$HOME"/a "$HOME"/b


    will copy the entire directory a to a new directory b




  2. Directories a and b exist:



    cp -a "$HOME"/a "$HOME"/b


    will copy the directory a inside directory b. So you'll get a "$HOME"/b/a directory as a result.




  3. Directories a and b exist:



    cp -a "$HOME"/a/* "$HOME"/b


    will copy the contents of a inside directory b but exclude hidden files and directories. While some shells have some options to include them, here the best approach would be:



    cp -a ~/a/. ~/b/



This is what I understand you want.







share|improve this answer














share|improve this answer



share|improve this answer








edited 11 hours ago









Stéphane Chazelas

331k58 gold badges644 silver badges1013 bronze badges




331k58 gold badges644 silver badges1013 bronze badges










answered 2 days ago









guillermo chamorroguillermo chamorro

44712 bronze badges




44712 bronze badges











  • 4





    Note that the very last command would not copy hidden files. This may not be an issue in this particular case, but it may well be an issue in the general case. To solve that, enable globbing of hidden files (in bash: shopt -s dotglob, in zsh: setopt GLOB_DOTS).

    – Kusalananda
    2 days ago








  • 3





    Change the star for a dot in the last command and it'll copy everything in a for you. See this answer for the explanation.

    – roaima
    yesterday













  • So much time passed since I last used shell globs - I forgot I have to use them here... A trouble of being a shell scripting amateur.

    – JohnDoea
    yesterday











  • @Kusalananda, in zsh, you'd rather use cp -a "$HOME"/a/*(D) "$HOME"/b to include hidden files rather than change a global setting. But cp -a ~/a/. ~/b/ would be best.

    – Stéphane Chazelas
    11 hours ago














  • 4





    Note that the very last command would not copy hidden files. This may not be an issue in this particular case, but it may well be an issue in the general case. To solve that, enable globbing of hidden files (in bash: shopt -s dotglob, in zsh: setopt GLOB_DOTS).

    – Kusalananda
    2 days ago








  • 3





    Change the star for a dot in the last command and it'll copy everything in a for you. See this answer for the explanation.

    – roaima
    yesterday













  • So much time passed since I last used shell globs - I forgot I have to use them here... A trouble of being a shell scripting amateur.

    – JohnDoea
    yesterday











  • @Kusalananda, in zsh, you'd rather use cp -a "$HOME"/a/*(D) "$HOME"/b to include hidden files rather than change a global setting. But cp -a ~/a/. ~/b/ would be best.

    – Stéphane Chazelas
    11 hours ago








4




4





Note that the very last command would not copy hidden files. This may not be an issue in this particular case, but it may well be an issue in the general case. To solve that, enable globbing of hidden files (in bash: shopt -s dotglob, in zsh: setopt GLOB_DOTS).

– Kusalananda
2 days ago







Note that the very last command would not copy hidden files. This may not be an issue in this particular case, but it may well be an issue in the general case. To solve that, enable globbing of hidden files (in bash: shopt -s dotglob, in zsh: setopt GLOB_DOTS).

– Kusalananda
2 days ago






3




3





Change the star for a dot in the last command and it'll copy everything in a for you. See this answer for the explanation.

– roaima
yesterday







Change the star for a dot in the last command and it'll copy everything in a for you. See this answer for the explanation.

– roaima
yesterday















So much time passed since I last used shell globs - I forgot I have to use them here... A trouble of being a shell scripting amateur.

– JohnDoea
yesterday





So much time passed since I last used shell globs - I forgot I have to use them here... A trouble of being a shell scripting amateur.

– JohnDoea
yesterday













@Kusalananda, in zsh, you'd rather use cp -a "$HOME"/a/*(D) "$HOME"/b to include hidden files rather than change a global setting. But cp -a ~/a/. ~/b/ would be best.

– Stéphane Chazelas
11 hours ago





@Kusalananda, in zsh, you'd rather use cp -a "$HOME"/a/*(D) "$HOME"/b to include hidden files rather than change a global setting. But cp -a ~/a/. ~/b/ would be best.

– Stéphane Chazelas
11 hours ago













0















cp safety tips:



copying a directory



Directories a and b exist:



cp -a a b/
cp -a -t b a


will copy the directory a inside directory b



Directory a exists but b doesn't:



cp -a a b/
cp -a -t b a


will generate a friendly error message



copying a file



Directory b exists



cp -T a b


will generate a friendly error message



Directory b does not exist



cp -T a b
will copy the file, to b





Note not all versions of cp/mv/ln have the -t or -T options, but all allow the / to ensure that the b is a directory. If they don't have these options, then there is no way to guarantee that b is not an existing directory.






share|improve this answer




























  • Not all implementations of cp have the -T option. Furthermore, some implementations require /. instead of just /. For example cp -a a/. b rather than cp -a a/ b. (And all implementations handle it, so there's no harm including the trailing dot on the source directory.)

    – roaima
    yesterday











  • I have already added a note about -T not being in all implementations.

    – ctrl-alt-delor
    16 hours ago











  • Yes... but on that same note, just / on its own also doesn't work everywhere, but /. (with that trailing dot) does.

    – roaima
    15 hours ago











  • @roaima can you edit the answer.

    – ctrl-alt-delor
    12 hours ago
















0















cp safety tips:



copying a directory



Directories a and b exist:



cp -a a b/
cp -a -t b a


will copy the directory a inside directory b



Directory a exists but b doesn't:



cp -a a b/
cp -a -t b a


will generate a friendly error message



copying a file



Directory b exists



cp -T a b


will generate a friendly error message



Directory b does not exist



cp -T a b
will copy the file, to b





Note not all versions of cp/mv/ln have the -t or -T options, but all allow the / to ensure that the b is a directory. If they don't have these options, then there is no way to guarantee that b is not an existing directory.






share|improve this answer




























  • Not all implementations of cp have the -T option. Furthermore, some implementations require /. instead of just /. For example cp -a a/. b rather than cp -a a/ b. (And all implementations handle it, so there's no harm including the trailing dot on the source directory.)

    – roaima
    yesterday











  • I have already added a note about -T not being in all implementations.

    – ctrl-alt-delor
    16 hours ago











  • Yes... but on that same note, just / on its own also doesn't work everywhere, but /. (with that trailing dot) does.

    – roaima
    15 hours ago











  • @roaima can you edit the answer.

    – ctrl-alt-delor
    12 hours ago














0














0










0









cp safety tips:



copying a directory



Directories a and b exist:



cp -a a b/
cp -a -t b a


will copy the directory a inside directory b



Directory a exists but b doesn't:



cp -a a b/
cp -a -t b a


will generate a friendly error message



copying a file



Directory b exists



cp -T a b


will generate a friendly error message



Directory b does not exist



cp -T a b
will copy the file, to b





Note not all versions of cp/mv/ln have the -t or -T options, but all allow the / to ensure that the b is a directory. If they don't have these options, then there is no way to guarantee that b is not an existing directory.






share|improve this answer















cp safety tips:



copying a directory



Directories a and b exist:



cp -a a b/
cp -a -t b a


will copy the directory a inside directory b



Directory a exists but b doesn't:



cp -a a b/
cp -a -t b a


will generate a friendly error message



copying a file



Directory b exists



cp -T a b


will generate a friendly error message



Directory b does not exist



cp -T a b
will copy the file, to b





Note not all versions of cp/mv/ln have the -t or -T options, but all allow the / to ensure that the b is a directory. If they don't have these options, then there is no way to guarantee that b is not an existing directory.







share|improve this answer














share|improve this answer



share|improve this answer








edited 12 hours ago

























answered yesterday









ctrl-alt-delorctrl-alt-delor

14.2k5 gold badges33 silver badges64 bronze badges




14.2k5 gold badges33 silver badges64 bronze badges
















  • Not all implementations of cp have the -T option. Furthermore, some implementations require /. instead of just /. For example cp -a a/. b rather than cp -a a/ b. (And all implementations handle it, so there's no harm including the trailing dot on the source directory.)

    – roaima
    yesterday











  • I have already added a note about -T not being in all implementations.

    – ctrl-alt-delor
    16 hours ago











  • Yes... but on that same note, just / on its own also doesn't work everywhere, but /. (with that trailing dot) does.

    – roaima
    15 hours ago











  • @roaima can you edit the answer.

    – ctrl-alt-delor
    12 hours ago



















  • Not all implementations of cp have the -T option. Furthermore, some implementations require /. instead of just /. For example cp -a a/. b rather than cp -a a/ b. (And all implementations handle it, so there's no harm including the trailing dot on the source directory.)

    – roaima
    yesterday











  • I have already added a note about -T not being in all implementations.

    – ctrl-alt-delor
    16 hours ago











  • Yes... but on that same note, just / on its own also doesn't work everywhere, but /. (with that trailing dot) does.

    – roaima
    15 hours ago











  • @roaima can you edit the answer.

    – ctrl-alt-delor
    12 hours ago

















Not all implementations of cp have the -T option. Furthermore, some implementations require /. instead of just /. For example cp -a a/. b rather than cp -a a/ b. (And all implementations handle it, so there's no harm including the trailing dot on the source directory.)

– roaima
yesterday





Not all implementations of cp have the -T option. Furthermore, some implementations require /. instead of just /. For example cp -a a/. b rather than cp -a a/ b. (And all implementations handle it, so there's no harm including the trailing dot on the source directory.)

– roaima
yesterday













I have already added a note about -T not being in all implementations.

– ctrl-alt-delor
16 hours ago





I have already added a note about -T not being in all implementations.

– ctrl-alt-delor
16 hours ago













Yes... but on that same note, just / on its own also doesn't work everywhere, but /. (with that trailing dot) does.

– roaima
15 hours ago





Yes... but on that same note, just / on its own also doesn't work everywhere, but /. (with that trailing dot) does.

– roaima
15 hours ago













@roaima can you edit the answer.

– ctrl-alt-delor
12 hours ago





@roaima can you edit the answer.

– ctrl-alt-delor
12 hours ago


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536559%2fcp-a-doesnt-work-to-copy-all-files-inside-a-directory%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...