Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My script use and modifies a shell variable. I need to always use:

source myscript

Is there a shorter way to call this script and have it modify the current shell's environment?

It can be elegantly done by using functions use as described in this answer, but I need a faster way.

share|improve this question
Do you mean faster as in - faster execution (performance), or faster setup (not having to modify .bashrc)? I ask because it never occurred to me wrapping it in a function would imply a performance deficit (if this is indeed the case). I suppose I could test this with time? – Emanuel Berg Sep 16 '12 at 21:51
up vote 5 down vote accepted

You can use . as a shorthand for source. From the bash(1) 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.
share|improve this answer
Thanks, this work with space before script filename – Yurij73 Sep 16 '12 at 17:22
Note that . is the POSIX standard name for this command (source is a bash-specific synonym). – chepner Sep 22 '12 at 4:40

Your Answer


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.