If you want to copy large number of files, it's not a good idea to use cp -r command directly because it will take a lot of time. It's better to use tar command to archive the files into a single file and then extract the file to the destination directory you want. The following is the Bash script to demonstrate how to copy large number of files efficiently:
1 2 3 4 5 6 7 8
#!/bin/bash # $1 is the directory in which files to be copied # $2 is the destination directory tar cvf /tmp/foo.tar $1 tar xvf /tmp/foo.tar -C $2 rm /tmp/foo.tar
Tested on: Ubuntu Linux 16.04, bash 4.3.46(1).
|||[Bash] Move Large Number of Files via tar Command|