You can copy files and directories using cp command. You need to provide the full or relative path of the files/directories of source and destination. In order to copy directories you need to use cp -R or -r or –recursive which copies directories recursively.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
mkdir mydir{1..4} ## create four file and directory touch myfile{1..4} ls cp myfile1 mydir1 ## copy myfile1 inside mydir1 ls mydir1 ## returns myfile1 cp mydir3 mydir4 ## does not works cp -r mydir3 mydir4 ## copy mydir3 recursively inside mydir4 ls mydir4 ## returns mydir3 cp mydir1/myfile1 mydir4/mydir3 ## copy myfile1 from mydir1 to mydir3 ls mydir4/mydir3 ## returns myfile1 rm -rf my* |