Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-14-2009, 09:15 PM   #1
Registered: Oct 2009
Posts: 104

Rep: Reputation: 22
Writing a function, question about a symbol's meaning

Generally I prefer to avoid asking simple questions, but I can't seem to get any information on this one. If I were to write this function, for example:

if [ -f ~/.bashrc ]; then
. ~/.bashrc

what does the '.' in the second line indicate ('.' ~/.bashrc)?
Old 10-14-2009, 09:17 PM   #2
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
sure its not a mistake? i dont see any reason for it to be there
Old 10-14-2009, 10:07 PM   #3
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
'.' is equivalent to 'source'. Both are bash builtins, so, check the bash man page to see what 'source' does.

The basic purpose of 'source' is to dump the contents of a shell script on the current shell, instead of spawning a new sub-shell. This is done this way because in bashrc you usually set a number of variables, and setting them into a subshell really makes no sense, since they will go away when the script exits. So, if you want a shell to run on the current shell you 'source' it instead of running it the traditional way.
Old 10-14-2009, 10:25 PM   #4
Registered: Oct 2009
Posts: 104

Original Poster
Rep: Reputation: 22

OK, I get the general idea. Now I just have to read the man for source and learn what sub-shells are. That's easy enough though, I can take it from here. Thank you!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: Problem writing simple LISP-function! raskol Programming 3 03-28-2008 06:20 PM
Slow file writing with 'fwrite' function in C-code... scho Programming 5 08-07-2006 12:42 AM
the meaning of no www (a question) salparadise General 8 08-25-2004 02:28 PM
writing a script to perform a function on each users mail folder jhill Linux - Newbie 2 08-24-2004 07:18 AM
Question: meaning of Hz in the Linux Kernel Arc4ne Linux - General 8 08-15-2004 10:12 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:19 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration