I need to find help for point command . such as in . ./my_script.sh (I mean the first point.)

I have already tried to find a man page using man . and man \.. How can I display a man page in which it explains the use of command .?

up vote 25 down vote accepted

Try using man sh or man bash or the man page for whatever shell you are using. (Maybe man $SHELL.)

This is officially not called the "point" command, but the source command. Searching for the word source may be helpful.

e.g., bash man page (search for "each builtin command"), and you'll quickly find the documentation.

As for explaining the use, I can do that right here. I will just refer to this as the source command, recognizing that it can be abbreviated to just a period when you're using some shells, and with some shells that command might need to be (because dot might be recognized but the entire word source might not be).

If you use the source command, your shell will read each line from the script file, and try to execute it. You need "read" permissions on the file. (It doesn't matter if you have "execute" permissions.) If you modify a variable, that is prone to affecting your current shell.

If, on the other hand, you just try to execute the file, then your shell will ask the operating system to take care of this request. This will require "execute" permissions. (On some systems, like OpenBSD, you won't need "read" permissions for this. On other systems, including many Unix variations, you will.) The file may need to start with an appropriate header (e.g., #!/bin/sh) so the operating system recognizes this to be a script file. The operating system will execute a copy of the requested shell, and tell that shell to run the contents of the script. If the shell environment is changed (e.g., a variable gets a new value, the working directory is changed (with cd), a file descriptor is redirected (with exec), etc.), it will impact only the sub-shell that was called for the script, and can't modify the environment in the parent shell that called the script file.

  • 15
    It's only source in bash. In the POSIX specification, it's called "the dot command" (and the source alias is not supported). – Charles Duffy Mar 22 at 17:13
  • 1
    A script needs read permissions, otherwise the interpreter can't access it. See Can a script be executable but not readable? – wjandrea Mar 22 at 20:04
  • 1
    Executing a script doesn't open a sub-shell, but just a normal child process, just like running a compiled program. See this answer on "Is a sub-shell the same thing as a child-shell?" – wjandrea Mar 22 at 20:21
  • 1
    So, I type man bash and then what, /.? Not very useful. /source would be useful, but for that you'd need to know that . and source are the same thing. – Joker_vD Mar 23 at 12:40
  • 1
    I found your paragraph "As for explaining the use..." slightly misleading, since it implies that it might be . and it might be source, but as @CharlesDuffy already mentioned, it's always . in any POSIX-compliant shell and only has the alias source in one shell. – Tom Fenech Mar 24 at 17:40

First of all you should invoke type ., you will probably get something like:

. is a shell builtin

Builtins are parts of your shell, they don't have their own manual pages. Some of them may seem to have them though, e.g. echo is a builtin in Bash but most likely there is a separate executable like /bin/echo in your system and in this case man echo refers to the latter. These two echos are probably not strictly equivalent.

Your shell may provide information about any builtin via help builtin; try help help, help type and finally:

help .

Builtins may also be listed in your shell's manual page. E.g. (in my Debian) Bash builtins are covered directly in man bash, yet for Zsh builtins man zsh tells me to run man zshbuiltins. In general shells may or may not explain their builtins.

  • 7
    +1 for pointing that . is a shell-built-in and This should be marked as answer because OP asks how to find help for . in *nix ?. – C0deDaedalus Mar 22 at 11:45
  • 7
    +1 for the use of type . to demonstrate that some commands are shell builtins. – Roger Lipscombe Mar 22 at 11:53
  • 1
    On most Debian, Bash builtins are also extracted to the bash-builtins(1) manual page, which is of a more convenient size. – Toby Speight Mar 22 at 14:06
  • Also, invoking "type" only works if you're using a shell which has a "type" builtin. If you happen to be using tcsh, "type ." gives "type: Command not found." – jamesqf Mar 22 at 21:43
  • 1
    Even . --help works – Digital Trauma Mar 23 at 18:17

No one else has mentioned it, as it's often forgotten.

Your biggest clue would of come from the helpful command whatis.

tim@musha ~ $ whatis .
builtins (1)         - bash built-in commands, see bash(1)
tim@musha ~ $ whatis source
builtins (1)         - bash built-in commands, see bash(1)
tim@musha ~ $ whatis bash
bash (1)             - GNU Bourne-Again SHell
tim@musha ~ $ whatis lynx
lynx (1)             - a general purpose distributed information browser for the World Wide Web
tim@musha ~ $ whatis linux
linux: nothing appropriate.
tim@musha ~ $ whatis whatis
whatis (1)           - display one-line manual page descriptions

EDIT:

Some people have pointed out in the comments that this isn't in some distrobutions - maybe it's an installable package, or enabled some how - I had it by default in gentoo ;)

It includes the wonderful which - which tells you which executable is called, and whereis which gives you all the paths to a executable you name, and it's man pages (if it exists in multiple paths).

  • 1
    Good hint but it seems it not works everywhere. For instance, in AIX with ksh, whatis . returns man: 0703-307 . is not found. – aturegano Mar 22 at 16:43
  • 4
    whatis . returns nothing on Ubuntu 16.04 – Vadim Kotov Mar 22 at 17:39
  • And ".: nothing appropriate." on OpenSuSE using tcsh. – jamesqf Mar 22 at 21:45
  • 2
    Ah, from it's own man page: "whatis - display one-line manual page descriptions." So it appears to be a very very short version of man. – Xen2050 Mar 23 at 10:34
  • A more compatible option may be: apropos (which should be the same as running "man -k"). For "." or "source" (which is part of the word "resource") this doesn't work too well, due to too many false positives, but likely would work for your other examples (bash, lynx, and whatis). On Debian Linux: "whatis ." gave ".: nothing appropriate." on OpenBSD, it resulted in 47 lines of output. For this specific example (using "whatis ." in Gentoo), the results may happen to just be uncommonly good (meaning that this technique isn't generally as useful for many other example scenarios). – TOOGAM Mar 25 at 2:00

man source will show the explanation that you need.

The dot is the same as the source command.

source executes the script in the current shell instead of in a subshell (it's the usual way).

Using source the variables set inside the script are preserved after the script has finished.

  • 2
    In what distro(s) does man source work? Not in my Debian, hence the question. – Kamil Maciorowski Mar 22 at 10:34
  • 1
    It works in CentOS 6.5. I guess is more related to the version of bash. In my case is 4.1.2(1) – jcbermu Mar 22 at 10:56
  • @jcbermu, no version of bash ships a separate man page for source upstream -- that's more likely something CentOS did. – Charles Duffy Mar 22 at 17:14
  • On my system, man source gives you man bash_builtins, which doesn’t explain anything,  but refers you to bash(1) – Scott Mar 22 at 20:59
  • 1
    On my system (Ubuntu LTS) man source gives me source(3tcl)... type command and then if the command is a builtin help command is probably the proper way... – Hastur Mar 22 at 22:41

The . is a synonym for the shell source command and so in bash, its syntax is displayed by...

help source

It functions exactly like the include and import commands in other languages in that it reads the target file and interprets it as if it were part of the current script. Thus, that file will execute in its entirety before the commands in the rest of the current script.

It should usually be at the beginning of the current script and is most often used to load variables and/or function definitions.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.