Search code examples
node.jsshellunixstatuscp

BASH: How to determine whether copying has finished?


I need to copy files from several folders by separate cp commands. How to ensure that every command ended only after what files are actually copied to disk? How can I find out that the copying was finished?

Thanks


Solution

  • If I understand correctly - separate your commands with &&. Like this:

    cp -r ./stuff/* ./somewhereelse/ && cp -r ./otherstuff/* ./somewhereelse/ && cp -r ./otherstuff/* ./anotherplace/
    

    The && will ensure the next command is run on success of the previous. You can chain as many commands as you like this way.