Re: what is the difference?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nifty Hat Mitch wrote:

On Fri, Sep 03, 2004 at 06:14:56PM -0700, Deepak Oberoi wrote:

what is the differecne between the following?
. /etc/sysconfig/sendmail
and
./etc/... (i know if the "." is followed by "/" then
it executes the file but dont know the what it does if
space is present between . and /)

This is a good question. You will see the " . file " construct used in lots of system shell scripts.

In effect the . causes the following file to be 'sourced' or read
as commands. This permits a set of shell scripts to share
common functions, setup and configuration flags.


Many of the scripts in /etc/init.d do this.  Read some of them...

The other form executes the file and returns and exit status (only
exit status and side effects impact the current shell).

The key difference is that the " . file" is executed by the current
shell and the second is executed by a sub shell and returns only
an exit status.

Note that the "./directory/file" syntax isn't only used in shell scripts. Nor is it specifically for executing programs. It's simply a way to reference a file relative to the current directory. "." is the current directory, "./file" is a file in the current directory, and "./directory/file" is a file in a subdirectory of the current directory.


Björn Persson



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux