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?...
- 05-12-2008 #1Just 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?
- 05-12-2008 #2
in your example it would copy the file cars to the directory you are
sitting in. It would leave the file named as carsIf 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.
- 05-12-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 2
Thank you for the explanation.
- 05-12-2008 #4Linux 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:
Instead of this one, which is equivalent:Code:cp /mnt/cdrom/myphotos/whateverfile.jpg .
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 doCode:cp /mnt/cdrom/myphotos/whateverfile.jpg /home/foo/docs/autralopitecus/
Or whatever. Always use with caution and double check before moving stuff around.Code:mv filename.jpg ..
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.
- 05-13-2008 #5
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.
- 05-13-2008 #6


Reply With Quote
