Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    quick question about cp command


    i would just mess around to figure this out, but i'm at work so i don't have the opportunity right now. however i am reading this book "understanding practical unix" by raymond greenlaw. for the cp command it says the syntax is:

    cp <name of file> <name of copied file>

    yet elsewhere i've read it goes like this:

    cp<name of file> <destination>

    now i'm confused at to how i would copy a file to a different destination.
    which is it?

    thanks, wes

  2. #2
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,732
    i usually rename files with cp and move files with mv

  3. #3
    Linux Guru budman7's Avatar
    Join Date
    Oct 2004
    Location
    Knee deep in Grand Rapids, Michigan
    Posts
    3,901
    This is from "man cp"
    If the last argument names an existing directory, cp copies each source
    file into that directory (retaining the same name). Otherwise, if only
    two files are given, it copies the first onto the second. It is an
    error if the last argument is not a directory and more than two non-
    option arguments are given.
    So it is both.
    Copy a single/multiple files to a Dir.
    Copy a single file, while rewriting another file.
    Depending on the arguments given.
    If you want to learn more about linux take a linux journey
    https://linuxjourney.com/
    Use CODE tags when posting output of commands. Thank you.
    https://www.linuxcounter.net/cert/608410.png

  4. $spacer_open
    $spacer_close
  5. #4

  6. #5
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,732
    Be sure and check out all the options on the "move" command manpage, too. It's good to know cp and mv:

    Code:
    man mv

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •