Copying & Moving FilesUnix also includes commands for copying and moving files: cp and mv. These commands enable you to copy or move one or more source files to a target file or directory. Tips
To copy a file to the same directoryType cp source-file target-file and press (Figure 21). For example, cp file.conf file.conf-orig would duplicate the file named file.conf and assign the name file.conf-orig to the duplicate copy. Tips
To copy files to another directoryType cp source-file … target-directory and press (Figure 21). For example, cp file.conf /Users/ronh/Documents would copy the file named file.conf in the current directory to the directory named Documents in my home folder. To copy files using a wildcardType cp followed by the wildcard search string for the source file and the name of the target directory and press (Figure 21). For example, cp *.conf Originals would copy all files ending with .conf in the current directory to the subdirectory named Originals. To rename a fileType mv source target and press (Figure 22). For example, mv file.conf file.conf-backup would rename file.conf as file.conf-backup. To move files to another directoryType mv source … directory and press (Figure 22). For example, mv file.conf Documents would move the file named file.conf in the current directory to the subdirectory named Documents. To move a file to another directory & rename itType mv source directory/filename and press (Figure 22). For example, mv file.conf-orig Documents/ file.conf-backup2 would move the file named file.conf-orig in the current directory to the subdirectory named Documents and name it file.conf-backup2 in its new location. |