Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell Command to copy a directory to another location

Tags:

bash

shell

php

In my web application I have to copy a directory and all its contents to another location. I want to use shell_exec function of PHP. But I can't find the command for that.

like image 506
techie_28 Avatar asked Dec 17 '11 09:12

techie_28


2 Answers

You can use:

cp -r source dest

Copies source and all contents of source inside dest.

like image 81
Tudor Avatar answered Oct 16 '22 00:10

Tudor


Define "location" more precisely. In any event:

  • if the directory is local: cp -r sourcedir destdir;
  • if it is remote, using scp: scp -r sourcedir user@targetmachine:destdir
like image 3
fge Avatar answered Oct 16 '22 02:10

fge