Mac Os X 10.4 Tiger (Visual Quickstart Guides)
Copying & Moving Files
Unix 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.
To copy a file to the same directory
Type cp source-file target-file and press 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.
To copy files to another directory
Type cp source-file … target-directory and press 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 wildcard
Type cp followed by the wildcard search string for the source file and the name of the target directory and press For example, cp *.conf Originals would copy all files ending with .conf in the current directory to the subdirectory named Originals. To rename a file
Type mv source target and press For example, mv file.conf file.conf-backup would rename file.conf as file.conf-backup. To move files to another directory
Type mv source … directory and press 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 it
Type mv source directory/filename and press 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. |