Reputation: 77
Request to need a help or information of the two operators . and `` in linux
e.g.
$ cp /home/uddi/root/hello `pwd`
and
$ cp /home/uddi/root/hello .
Please suggest me
Upvotes: 1
Views: 137
Reputation: 20022
A small difference occurs after mkdir /tmp/lost; cd /tmp/lost; rmdir /tmp/lost
.
After these stupid commands pwd
will be a filename (/tmp/lost) and the current dir .
does not exist.
I think you want an error when you try to copy a file in the "current" dir, so I would prefer the .
. It will also avoid an extra command.
Upvotes: 2
Reputation: 3158
When you enclose something between back-ticks, the shell will run the contents and use the output from that/those command/s as an argument for the main command being run. In your example, the shell will run the pwd
command and use its output as the 2nd argument to the cp
call.
In your second example, the .
character is a link to the current directory. The reason that both do the same thing is that .
links to the current directory and pwd
will print out the current working directory, which are the same. In this case, you are using two methods to expand to the same path.
EDIT:
You can see somewhat how .
works by running ls -a
in any directory. It will show you the .
and ..
directories, which are filesystem-level links to the current and parent directory, respectively.
Upvotes: 2