Copying files from one place to another seems a trivial task hardly worth mentioning in an advanced shell-scripting book. However, copying groups of files with the typical
cp command doesn't result in a true copy. You might expect an exact duplicate of the source files, but there may be soft links, hard links, subdirectories, pipes, dot files, and regular files, among others, and the
cp command doesn't work as you might expect with all of them. You need to make a few tweaks to get a copy command that performs well for all file and link types. For testing purposes, I created a directory that contains some of each of these file types that can be used to check whether the copy has been performed correctly.