Find the answer to your Linux question:
Results 1 to 6 of 6
Trying to learn Linux and trying to figure out what the "." does at the end of this command line. cp /u/llos/pub/cars . any help?...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    2

    Question regarding command.

    Trying to learn Linux and trying to figure out what the "." does at the end of this command line.

    cp /u/llos/pub/cars .

    any help?

  2. #2
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    in your example it would copy the file cars to the directory you are
    sitting in. It would leave the file named as cars
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  3. #3
    Just Joined!
    Join Date
    May 2008
    Posts
    2
    Thank you for the explanation.

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    The whole story is this: on each directory (call them "folders" if you prefer) there are always, at least, two subdirectories within it. Those to entries are created at the very same time you create that folder.

    You can see them if you cd into any dir and use this command:

    Code:
    ls -a

    One is '.', which points to the same directory. As silly as it seems, it has it's uses, as you have already discorered. For example, if you are into /home/foo/docs/autralopitecus/ and you can to copy a file from /mnt/cdrom/myphotos/, you don't have to write the two paths. You just do:

    Code:
    cp /mnt/cdrom/myphotos/whateverfile.jpg .
    Instead of this one, which is equivalent:

    Code:
    cp /mnt/cdrom/myphotos/whateverfile.jpg /home/foo/docs/autralopitecus/
    The second misterious entry is '..' (two dots), which means "the parent dir". So, if you are into a given dir, and you want to move a file from that dir to the previous (as in parent) one, then you just do

    Code:
    mv filename.jpg ..
    Or whatever. Always use with caution and double check before moving stuff around.

    This is not exclusive to linux. Unix, bsd, msdos and even windows use this same dot and dot-dot stuff, only that you don't see that when you are clicking into a window.

  5. #5
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    Nice explaination
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  6. #6
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    845
    Quote Originally Posted by i92guboj View Post
    The whole story is this: on each directory (call them "folders" if you prefer) there are always, at least, two subdirectories within it.
    Just to be picky, the root directory doesn't have a parent directory so there is no '..' for /
    Linux User #453176

Posting Permissions

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