What are other common cp command options?

074

Here are some common options for the cp command:

  1. -r: Recursively copy directories and their contents.

    cp -r source_directory/ destination_directory/
  2. -i: Interactive mode; prompts before overwriting files.

    cp -i source_file destination_file
  3. -u: Copy only when the source file is newer than the destination file or when the destination file is missing.

    cp -u source_file destination_file
  4. -p: Preserve file attributes (timestamps, permissions, etc.).

    cp -p source_file destination_file
  5. -v: Verbose mode; shows the files being copied.

    cp -v source_file destination_file
  6. -a: Archive mode; preserves attributes and copies directories recursively.

    cp -a source_directory/ destination_directory/

These options can be combined as needed. For example:

cp -rv source_directory/ destination_directory/

If you have more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!