Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: use of period in cp command

  1. #1
    Join Date
    May 2013
    Beans
    7

    use of period in cp command

    hello everyone
    im a beginner in ubuntu , so to get some idea in command line i've started reading "The Linux Command Line"
    while reading i was not able to understand the meaning of period at the end in this command:
    [me@linuxbox playground]$ cp /etc/passwd .
    without using period it gives :
    ansh@ansh-Lenovo-G580:~/playground$ cp /etc/passwd
    cp: missing destination file operand after ‘/etc/passwd’
    Try 'cp --help' for more information.

    can someone tell me the meaning of period at the end and its importance , in simple terms if possible

  2. #2
    Join Date
    Mar 2007
    Location
    Denver, CO
    Beans
    7,554
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: use of period in cp command

    . means current working directory
    .. (two periods) means one directory higher in the directory tree. (for example if you were in /home/user, typing cd .. would move you to /home)

  3. #3
    Join Date
    Feb 2008
    Location
    Planet earth, for now.
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: use of period in cp command

    What are you actually trying to do? If you want to copy the /etc/passwd directory/file to somewhere else, then:

    Code:
    sudo cp /etc/passwd /etc/passwd.backup
    ... would create a copy of 'passwd', file or directory, called 'passwd.backup' in the /etc directory.

    No idea about the '.'. Please use code tags for clarity when posting code. You can use the [code] tags or 'Go Advanced', highlight the code and click the hash '#'.

  4. #4
    Join Date
    Feb 2008
    Location
    Planet earth, for now.
    Beans
    Hidden!
    Distro
    Xubuntu

  5. #5
    Join Date
    May 2013
    Beans
    7

    Re: use of period in cp command

    im sorry for not clarifying this properly
    as stated earlier im a beginner in this and this is actually my first post

    in the book using this command :
    Code:
    [me@linuxbox playground]$ cp /etc/passwd .
    he is trying to copy /etc/passwd file in a new directory named "playground"

    so i wanted to ask the meaning of period symbol at the end of the command and why it is imp

    and when i tried doing the same thing without using period it gave me this reply in my terminal :
    Code:
    ansh@ansh-Lenovo-G580:~/playground$ cp /etc/passwd
    cp: missing destination file operand after ‘/etc/passwd’
    Try 'cp --help' for more information.

    now am i using the code tags properly ?

  6. #6
    Join Date
    May 2013
    Beans
    7

    Re: use of period in cp command

    * mistake again
    last command was:

    Code:
    ansh@ansh-Lenovo-G580:~/playground$ cp /etc/passwd
    cp: missing destination file operand after ‘/etc/passwd’
    Try 'cp --help' for more information.

  7. #7
    Join Date
    May 2013
    Beans
    7

    Re: use of period in cp command

    thanks for replying
    but is it imp to use . at the end of cp command for copying?

  8. #8
    Join Date
    Feb 2008
    Location
    Planet earth, for now.
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: use of period in cp command

    Have no idea about the period in this command, or much about the command, if it is intended to copy /etc/passwd file/directory into a new directory named "playground". What happens when you run the command with the period?

    Code:
    sudo mkdir/etc/playground
    sudo cp /etc/passwd /etc/playground
    The first command creates the directory 'playground', the second copies 'passwd' to the directory '/etc/playground'.
    Last edited by Bucky Ball; August 4th, 2013 at 05:42 AM.

  9. #9
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    4,171
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: use of period in cp command

    Quote Originally Posted by anshul001 View Post
    thanks for replying
    but is it imp to use . at the end of cp command for copying?
    Only if you want to copy it into the directory your are currently in.
    The period stands for the current directory or place you're at.
    With each additional period moving up the ladder, as it were, until you reach root /.

    But when copying, you need to have a place to copy to.
    Thus the missing destination.
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  10. #10
    Join Date
    May 2013
    Beans
    7

    Re: use of period in cp command

    thanks for your help
    using period at the end also copies the file
    i just want to know the meaning and importance of period at the end of the command

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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