Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
$ whatis source
source: nothing appropriate.
$ man source
No manual entry for source
$ source
bash: source: filename argument required
source: usage: source filename [arguments]

It exists, it is runnable, why there is no documentation about it in ubuntu? What does it do? How can I install documentation about it?

share|improve this question
related: superuser.com/questions/176783/… – lesmana Jan 17 '11 at 21:59

5 Answers

up vote 19 down vote accepted

source is a bash shell built-in command that executes the content of the file passed as argument, in the current shell. It has a synonym in '.' (period).

Syntax
      . filename [arguments]

      source filename [arguments]
share|improve this answer
Is source a bash specific command or do other shells have it too? (I'm asking to get tags right on the question...) – Jonik Sep 24 '09 at 11:17
1  
Afaik, source was present in the Bourne shell and hence probably present in all its descendants. en.wikipedia.org/wiki/Bourne_shell. I know that not all shells have the source command, less certain about which shells do contain it. – nagul Sep 24 '09 at 11:47

. (a period) is a bash shell built-in command that executes the commands from a file passed as argument, in the current shell. 'source' is a synonym for '.'.

From Bash man page:

. filename [arguments]
source filename [arguments]
       Read  and  execute  commands  from filename in the current shell
       environment and return the exit status of the last command  exe‐
       cuted from filename.  If filename does not contain a slash, file
       names in PATH are used to find the  directory  containing  file‐
       name.   The  file  searched  for in PATH need not be executable.
       When bash is  not  in  posix  mode,  the  current  directory  is
       searched  if no file is found in PATH.  If the sourcepath option
       to the shopt builtin command is turned  off,  the  PATH  is  not
       searched.   If any arguments are supplied, they become the posi‐
       tional parameters when  filename  is  executed.   Otherwise  the
       positional  parameters  are unchanged.  The return status is the
       status of the last command exited within the  script  (0  if  no
       commands  are  executed),  and false if filename is not found or
       cannot be read.
share|improve this answer

'source' is the long version of '.' command.. on the bash prompt one can do

source ~/.bashrc

to reload your (changed?) bash setting for current running bash

short version would be:

. ~/.bashrc

the man page:

. filename [arguments]
source filename [arguments]
    Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename. If filename does not contain a slash, file names in PATH are used to find the directory containing filename. The file searched for in PATH need not be executable. When bash is not in posix mode, the current directory is searched if no file is found in PATH. If the sourcepath option to the shopt builtin command is turned off, the PATH is not searched. If any arguments are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters are unchanged. The return status is the status of the last command exited within the script (0 if no commands are executed), and false if filename is not found or cannot be read.

edit: can't get the above to format in a nice way, sorry

share|improve this answer

It is useful to know the 'type' command:

> type source
source is a shell builtin

whenever something is a shell builtin it is time to do man bash.

share|improve this answer

This is a shell built-in command, read the manual for your shell.

which source

man bash
share|improve this answer
1  
Mentioning "shell built-in command" is good, but this answer would be better if combined with that of Jawa. :) – Jonik Sep 24 '09 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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