LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What does it mean this command cp /etc/. /tmp ? (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-it-mean-this-command-cp-etc-tmp-659298/)

nanosec 07-30-2008 12:31 PM

What does it mean this command cp /etc/. /tmp ?
 
What does it mean this command cp /etc/. /tmp ?

I don't understand about symbol "." after /etc/.

Please, help to clarify.

Thanks

pixellany 07-30-2008 01:04 PM

What is the context of this? (or--what are you trying to do?) On the surface of it, it does not make much sense.

Possible (special) meanings of "." in Bash:
current directory
prefix for a hidden file
any character (in a regular expression)

Mr. C. 07-30-2008 02:29 PM

[ edit: Never mind - misread, but I'll leave my original interpretation anyway ]

It means somebody concatenated two path components together, but didn't bother with path canonicalization. The internal /./ is superfluous and can be removed.

Eg:

non-canonical path: /etc/. /tmp
canonical path: /etc/tmp

This routinely occurs when you have two vars combined into a path:

Code:

$ base="/etc"
$ subdir="./tmp"
$ dir=$base/$subdir
$ echo $dir
/etc/./tmp

You will also see this intentional usage with the home directory in /etc/passwd; it used specially by certain programs for path substitution.

johnsfine 07-30-2008 02:39 PM

Quote:

Originally Posted by Mr. C. (Post 3231302)
It means somebody concatenated two path components together

Did you fail to see the blank between the . and the following / in the original post? Or did you assume it was a typo? Or you have some other reason why it doesn't invalidate you answer?

But, so far as I understand, the command in that post does nothing, because it interprets /etc/. as /etc and cp skips directories.

Mr. C. 07-30-2008 03:03 PM

Yes, I failed. It appeared as a single path to me. This is where a fixed-width font is useful (eg. place such text within [ code ] [ / code ] tags. Since font size/family is a browser's/user's choice, on my system the space is very hard to distinguish at 1600x1200 sitting 3 feet away from the monitor.

I knew the command would fail:

Code:

$ cp empty/. ./newdir
cp: empty/. is a directory (not copied).

so assumed the command was incomplete.

Thanks for the clarification.

johnsfine 07-30-2008 03:52 PM

I can't see the blank either. I wondered whether one was there and tried selecting it with the cursor tool. Since I could select it, I knew it was there. Of course I agree such things should use code tags so we can see them.

But I still have no good guess what mistake by the OP or by whatever source he copied from is responsible for the useless command.


All times are GMT -5. The time now is 11:42 AM.