• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. Unix Basics For Mac OS X > Copying & Moving Files

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.

Tips

  • Why copy a file? Usually, to make a backup. For instance, before you edit a configuration file, you should create a backup copy of the original. This way you can revert back to the original if your edits “break” something in the file.

  • The source-file operand can be a file or a directory.

  • The mv command can also be used to rename a file.

  • The cp and mv commands support several options. You can learn more about them in the man pages for these commands. Type man cp or man mv and press to view each command's man pages.

  • Unix does not confirm that a file has been copied or moved when you correctly enter command (Figure 22). To check to see if a file has been copied or moved to the correct destination, you can use the ls command to get a listing for the target directory. The ls command is covered earlier in this chapter.

    Figure 22. Here's what the cp and mv commands might look like when used. Note that there's no indication if a copy or move was successfully completed.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint